Jump to content

امتداد:DiscordRCFeed

From mediawiki.org
This page is a translated version of the page Extension:DiscordRCFeed and the translation is 92% complete.
الدليل المرجعي لامتدادات ميدياويكي
DiscordRCFeed
حالة الإصدار مستقر
تنفيذ إشعار
بيان يوفر فرميتات RCFeed و RCFeedFormatter الفرعية لـ Discord
المؤلف/المؤلفون
آخر إصدار 1.0.3
سياسة التوافق تصدر اللقطات البرمجية مع ميدياويكي. الإصدار الرئيسي لا يتوافق مع الإصدارات السابقة.
MediaWiki >= 1.35.0
PHP >= 7.3
تغييرات قاعدة البيانات لا
ترخيص رخصة MIT
التنزيل
تنزيلات ربع سنوية 11 (Ranked 120th)
ترجم الامتداد DiscordRCFeed لو كان متوفرا على translatewiki.net
المسائل المهام المفتوحة · الإبلاغ عن عطل تقني

DiscordRCFeed extension provides the Discord versions of FormattedRCFeed and RCFeedFormatter subclasses which can be used in $wgRCFeeds .

المتطلبات

  • إعداد تغذية تتطلب الإمتداد PHP sockets. إذا لم يتم تمكين الامتداد، قد تعمل الإجراءات مثل التحريرات، وعمليات النقل، إلخ، ولكن قد لا يتم تسجيل الإجراء في التغييرات الأخيرة على الإطلاق. انظر Manual:$wgRCFeeds للتفاصيل
  • يجب أن يكون لدى Apache علامة NE (NoEscape) لمنع مشاكل في عناوين URL. حسب الافتراض يجب أن يكون لديك هذا تمكين.

التنصيب

  • إنشاء الويب هوك Discord الجديدة لقناة الخاص بك يمكنك إنشاء وإدارة الويب هوكات لقناة الخاص بك عن طريق النقر على رمز الإعدادات بجوار اسم القناة في تطبيق Discord. اقرأ المزيد من هنا: https://support.discord.com/hc/articles/228383668
  • بعد إعداد الويب هوك سوف تحصل على عنوان URL الويب هوك نسخ عنوان URL كما ستحتاج إليه في الخطوات التالية.
  • نزّل الملف/الملفات وضعها في دليل يحمل اسم ‎DiscordRCFeed داخل مجلد ‎extensions/‎ لديك.
    يجب على مطوري البرمجيات والمساهمين بالكود البرمجي تثبيت الامتداد من غت بدلا من ذلك، مستخدمين:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscordRCFeed
  • أضف الكود التالي في الجزء الأسفل من ملف LocalSettings.php :
    wfLoadExtension( 'DiscordRCFeed' );
    $wgRCFeeds['discord'] = [
    	// Your Discord webhook URL here.
    	'url' => 'https://discord.com/api/webhooks/xx/xxxx',
    ];
    
  • Yes تم التنفيذ – اذهب إلى Special:Version على موقع الويكي لديك كي تتحقق من أن الامتداد قد ثبت بنجاح.

خيارات إضافية

You can set the element that has the following key for the $wgRCFeeds['discord']:

الاسم القيمة المحتملة الوصف افتراضي
خيارات عرض
'style' 'structure', 'embed' or 'inline' تحديد كيفية عرض المغذية. 'structure'
'user_tools' See below Controlling which tools to be included displaying the feed. See #Controlling Page Tools and User Tools below for details. defined in code
'page_tools'
التغييرات التي تجاهل
'omit_bots' true or false Whether to skip bot edits. Same as described on Manual:$wgRCFeeds . false
'omit_anon' Whether to skip anon edits. Same as described on Manual:$wgRCFeeds .
'omit_user' Whether to skip registered users. Same as described on Manual:$wgRCFeeds .
'omit_minor' Whether to skip minor edits. Same as described on Manual:$wgRCFeeds .
'omit_patrolled' Whether to skip patrolled edits. Same as described on Manual:$wgRCFeeds .
'omit_talk' Whether to skip changes on talk pages.
'omit_namespaces' See below Lists for changes to be ignored by the feed. See #Filtering Notifications below for details. []
'omit_types'
'omit_log_types' ['patrol']
'omit_log_actions' []
'omit_content_models'
تغييرات في نطاق
'only_talk' true or false If this is true, only changes on talk pages would be displayed as all other changes are ignored. false
'only_namespaces' See below If not empty, only changes that match the given condition(s) are sent. See #Filtering Notifications below for details. []
'only_types'
'only_log_types'
'only_log_actions'
'only_content_models'
Other
'request_replace' See below An array which used to override the post data of the webhook request. See #Webhook Request Overriding below for details. []

Filtering Notifications

$wgRCFeeds['discord']['omit_namespaces'] is a list that contains namespaces should be omitted.

// Disabling notifications from user talk page
$wgRCFeeds['discord']['omit_namespaces'] = [ NS_USER_TALK ];

// Disabling notifications from talk pages.
$wgRCFeeds['discord']['omit_namespaces'] = [
	NS_TALK,
	NS_USER_TALK,
	NS_PROJECT_TALK,
	NS_FILE_TALK,
	NS_MEDIAWIKI_TALK,
	NS_TEMPLATE_TALK,
	NS_HELP_TALK,
	NS_CATEGORY_TALK,
	NS_MODULE_TALK,
];

The others are similar.

  • 'omit_types' can contain RC_EDIT, RC_NEW, RC_LOG and RC_EXTERNAL. (see more) Note that RC_CATEGORIZE is always omitted by the same cause of phab:T127360.
  • 'omit_log_types' can contain'move','protect', 'delete', 'block', 'upload'...
  • 'omit_log_actions' can contain'move/move-noredirect', 'block/block', 'block/unblock'... (see more)
  • 'omit_content_models' can containCONTENT_MODEL_WIKITEXT, CONTENT_MODEL_JAVASCRIPT, CONTENT_MODEL_CSS... (see more)

The next example shows how to disable the new user notification.

$wgRCFeeds['discord']['omit_log_types'] = [
	'newusers',
];

السيطرة على أدوات الصفحة وأدوات المستخدم

أدوات الصفحة وأدوات المستخدم هي أدوات تظهر بعد الصفحة أو رابط المستخدم.

الخيارات الوصف افتراضي
'user_tools' If this is false, user links of the feed would not get additional tool links. (talk | contribs)
'page_tools' If this is false, page links of the feed would not get additional tool links. (hist | diff)
// Remove page tools
$wgRCFeeds['discord']['page_tools'] = false;

// Redefine user tools
$wgRCFeeds['discord']['user_tools'] = [
	[
		'target' => 'special',
		'special' => 'Block',
		'text' => 'IP Block'
	],
	[
		'target' => 'talk',
		'text' => 'Discussion'
	],
	[
		'target' => 'special',
		'special' => 'Contributions',
		// message would be shown if 'msg' is given.
		'msg' => 'contribslink'
	],
];

The full default values can be found in includes/Constants.php.

Webhook Request Overriding

$wgRCFeeds['discord']['request_replace'] is an associative array which used to override the post data of the webhook request. You can set username or avatar using this instead of setting in Discord. Visit https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params for all available parameters.

$wgRCFeeds['discord']['request_replace'] = [
	'username' => 'Captain Hook',
	'avatar_url' => 'https://upload.wikimedia.org/wikipedia/commons/7/79/MediaWiki-48px.png'
];

Next example shows how to reuse your icon set in $wgLogos .

$wgRCFeeds['discord']['request_replace'] = [
	'avatar_url' => "$wgCanonicalServer/${wgLogos['icon']}",
];

Registering Multiple Webhooks

You can register multiple webhooks with separate settings. Only the important part is that all keys of the feeds you want to must start with 'discord', for example, 'discord', 'discord-second', 'discord2' and 'discord_copy' are valid keys.

wfLoadExtension( 'DiscordRCFeed' );
// Divide anonymous and registered users.
$wgRCFeeds = [
	'discord' => [
		'url' => 'https://discord.com/api/webhooks/aaa/xxxx',
		'omit_user' = true,
	],
	'discord_registered' => [
		'url' => 'https://discord.com/api/webhooks/bbb/xxxx',
		'omit_anon' = true,
	],
];

أمثلة الإعداد

Splitting changes on talk pages from others

$wgRCFeeds = [
	'discord_content' => [
		'url' => 'https://discord.com/api/webhooks/aaa/xxxx',
		'omit_talk' => true,
	],
	'discord_talk' => [
		'url' => 'https://discord.com/api/webhooks/bbb/xxxx',
		'only_talk' => true,
	],
];

Note that this is not suitable for wiki where النقاشات المهيكلة is enabled because a page on NS_TOPIC is not considered as a talk page by Title::isTalkPage(). In that case, filtering by namespace is only the solution:

$wgRCFeeds['discord'] = [
	'url' => 'https://discord.com/api/webhooks/aaa/xxxx',
	'omit_namespaces' => [
		NS_TALK,
		NS_USER_TALK,
		NS_PROJECT_TALK,
		NS_FILE_TALK,
		NS_MEDIAWIKI_TALK,
		NS_TEMPLATE_TALK,
		NS_HELP_TALK,
		NS_CATEGORY_TALK,
		829, // NS_MODULE_TALK, if Scribunto is installed
		2600, // NS_TOPIC
		// could be longer
	],
];
$wgRCFeeds['discord_talk'] = [
	'url' => 'https://discord.com/api/webhooks/bbb/xxxx',
	'only_namespaces' => $wgRCFeeds['discord']['omit_namespaces'],
];

Reusing a feed setting for multiple servers

// Define the source.
$wgRCFeeds['discord1'] = [
	'url' => 'https://discord.com/api/webhooks/aaa/xxxx',
	'omit_bots' => true,
	'omit_minor' => true,
	'omit_nemespaces' => [
	    NS_PROJECT,
	    NS_TEMPLATE,
	    NS_MODULE,
	    NS_USER,
    ],
    'only_types' => [ RC_EDIT, RC_NEW ],
];

// Reuse the same configuration.
$wgRCFeeds['discord2'] = $wgRCFeeds['discord1'];
$wgRCFeeds['discord2']['url'] = 'https://discord.com/api/webhooks/bbb/xxxx',

// Reuse but with some tweak.
$wgRCFeeds['discord3'] = $wgRCFeeds['discord1'];
$wgRCFeeds['discord3']['url'] = 'https://discord.com/api/webhooks/ccc/xxxx',
$wgRCFeeds['discord3']['omit_minor'] = false;
unset( $wgRCFeeds['discord3']['only_types'] );

تغييرات الجافا سكريبت فقط

$wgRCFeeds = [
	'discord' => [
		'url' => 'https://discord.com/api/webhooks/xxx/xxxx',
		'only_content_models' => CONTENT_MODEL_JAVASCRIPT,
	],
];

ملاحظات

  • Basically, DiscordRCFeed is a fork of DiscordNotifications , but heavily modified.
  • The basic usage of $wgRCFeeds is like below:
    $wgRCFeeds['discord'] = [
        'formatter' => 'MediaWiki\Extension\DiscordRCFeed\DiscordRCFeedFormatter',
    	'url' => 'https://discord.com/api/webhooks/xxx/xxxx',
    ];
    
    But because the 'formatter' value is too long for the end-users, DiscordRCFeed automatically uses 'MediaWiki\Extension\DiscordRCFeed\DiscordRCFeedFormatter' as its default formatter, if the value is omitted and the key of RCFeed is starts with 'discord'.

انظر أيضا


This extension was originally made for Femiwiki.