قالب:Bots

من موسوعة المزرعة
اذهب إلى التنقل اذهب إلى البحث
Other languages square icon.svg
لا يزال النص الموجود في هذه الصفحة في مرحلة الترجمة إلى العربية. إذا كنت تعرف اللغة المستعملة، لا تتردد في الترجمة.

هذا القالب يوضح للبوت أو أي أداة تحرير آلية أنه يجب ألا يقوم بتحرير الصفحة التي تحتوي هذا القالب. يُستخدم القالب لمنع مُعظم البوتات (كل البوتات التي تستخدم هذه الخاصية) أو تمنع بوتات محددة بالاسم أو تمنع وظيفة محددة. على سبيل المثال، يمكن استخدامه للسماح أو لمنع رسائل البوت أو لجعل بوتات الصيانة تتخطى صفحةٍ ما. هذا القالب يجب استخدامه بعناية خارج صفحات المستخدمين لكي لا نفقد تعديدلات مهمة للبوتات.

Explicitly opting-in has the advantage of receiving useful changes or targeted posts a bot might otherwise skip by following "opt-out" behavior by default. Users should be aware that by opting-out of bot posts, they will not be notified of matters relating to material they have edited or uploaded, which are tagged or scanned by bots per policy.

In particular, in the encyclopedia spaces:

  • Avoid using the template as a blunt instrument
  • Address the root problem with the bot owner or bot community
  • Remove the template tag once the underlying problem has been resolved.

Important notes[عدل]

Most bots will NOT understand these templates when they are indirectly transcluded. For example, the {{ويكيبيدي متوفي}} template attempts to transclude {{Bots}} into the pages on which it is used, but a bot that is using regex to parse the text of the page will not notice that template.

Most bots will not disregard the template if it is inside of <nowiki> ... </nowiki> tags. For example, if you are discussing the templates with another editor, please use the {{قا}} template, e.g. {{قا|Bots}}, which will show {{Bots}}, rather than <nowiki>{{nobots}}</nowiki>, which will possibly be parsed as intending to ban bots from the page.

This template has no effect on mass messages. To exclude those, add Category:تم إلغاء الاشتراك في تسليم الرسالة to your talk page.

استخدام القالب[عدل]

{{nobots}}                منع جميع البوتات (اختصار)
{{bots}}                  السماح لجميع البوتات (اختصار)
{{bots|allow=<botlist>}}  منع جميع البوتات غير الموجودة في القائمة
{{bots|deny=<botlist>}}   منع جميع البوتات الموجودة في القائمة
يتم فصل أسماء البوتات في بفاصلة <botlist> مثل:
  {{bots|allow=HagermanBot,Werdnabot}}
  {{bots|deny=AWB}}
<botlist> يكون أيضًا أن تكون قيمة الوسيط "none" أو "all" كما في الأمثلة التالية:
  {{bots|allow=all}}      السماح لجميع البوتات
  {{bots|allow=none}}     منع جميع البوتات
  {{bots|deny=all}}       منع جميع البوتات
  {{bots|deny=none}}      السماح لجميع البوتات

Incorrect syntax[عدل]

This syntax looks correct, but depending on the individual bot may not have the intended effect. This statement may deny neither Bot1 nor Bot2, only one of the two bots, or both bots as intended.

{{bots|deny=Bot1|deny=Bot2}} INCORRECT

Instead, write:

{{bots|deny=Bot1,Bot2}}      CORRECT

Message notification opt out[عدل]

Another option is to opt out of specific types of messages for users who wish to be notified of certain problems, but not others. Users should be aware that by opting-out of specific notification posts, they will not be notified of matters relating to material they have edited or uploaded, which are tagged per policy. Actions (such as deletion) may be executed without you being notified as a result. By applying this to your own user talk page, you agree to this consequence. Applying this to a user talk page other than your own will be considered vandalism. All bots and scripts that leave messages on a user's talk page are encouraged to add this capability.

By adding this to a user's talk page, a user may still receive these messages by non-compliant bots or scripts, or humans who add the tag manually.

{{bots|optout=all}}            Opt out of all messages (see limitations below).
{{bots|optout=nosource}}       Opt out of no source messages.
{{bots|optout=nolicense}}      Opt out of no license messages.
{{bots|optout=orfud}}          Opt out of orphaned fair use messages.
{{bots|optout=npd}}            Opt out of no permission messages.
{{bots|optout=norationale}}    Opt out of no rationale messages.
{{bots|optout=replaceable}}    Opt out of replaceable fair use messages.
{{bots|optout=bettersource}}   Opt out of better source request messages.
{{bots|optout=afd}}            Opt out of articles for deletion messages or variant forms.
{{bots|optout=ifd}}            Opt out of images for deletion messages or variant.
{{bots|optout=prod}}           Opt out of prod warning.

Items can be combined by putting a comma between options

{{bots|optout=nosource,nolicense}}                 Opt out of no source, and no license messages.
{{bots|optout=orfud,norationale,replaceable}}      Opt out of fair use messages.

Restrictions of messages that can be opted out[عدل]

Some message notifications are not allowed to be opted out. These include:

  1. Copyright violation notifications
  2. Vandalism (and other) warning notices.
  3. مستخدم:SineBot's notices for not signing posts
  4. Any message tag that isn't included as a way of opting out above. (Is there one that should be included? Leave a message on the talk page.)
  5. Messages delivered via the MassMessage extension (to opt out of MassMessage add Category:تم إلغاء الاشتراك في تسليم الرسالة to your page)

Implementation[عدل]

  • Pywikibot supports bots and nobots since r4096. The templates may be ignored using a parameter.
  • Since version 3.2.0.0 AutoWikiBrowser fully supports {{bots}} and {{nobots}}. Additionally, pseudo-username AWB can be specified to ban all AWB-based bots from the page. However, AWB has an option to ignore these templates.
  • Opt out message notification was introduced here April 3, 2008. Individual bot/script implementation will vary and notice above of implementation may not include this feature.

Example implementations[عدل]

PHP[عدل]

function allowBots( $text ) {
    global $user;
    if (preg_match('/\{\{(nobots|bots\|allow=none|bots\|deny=all|bots\|optout=all|bots\|deny=.*?'.preg_quote($user,'/').'.*?)\}\}/iS',$text))
      return false;
    if (preg_match('/\{\{(bots\|allow=all|bots\|allow=.*?'.preg_quote($user,'/').'.*?)\}\}/iS', $text))
      return true;
    if (preg_match('/\{\{(bots\|allow=.*?)\}\}/iS', $text))
      return false;
    return true;
}

Perl[عدل]

sub allow_bots {
    my($text, $user, $opt) = @_;
    return 0 if $text =~ /{{[nN]obots}}/;
    return 1 if $text =~ /{{[bB]ots}}/;
    if($text =~ /\{\{[bB]ots\s*\|\s*allow\s*=\s*(.*?)\s*}}/s){
        return 1 if $1 eq 'all';
        return 0 if $1 eq 'none';
        my @bots = split(/\s*,\s*/, $1);
        return (grep $_ eq $user, @bots) ? 1 : 0;
    }
    if($text =~ /\{\{[bB]ots\s*\|\s*deny\s*=\s*(.*?)\s*}}/s){
        return 0 if $1 eq 'all';
        return 1 if $1 eq 'none';
        my @bots = split(/\s*,\s*/, $1);
        return (grep $_ eq $user, @bots) ? 0 : 1;
    }
    if(defined($opt) && $text =~ /\{\{[bB]ots\s*\|\s*optout\s*=\s*(.*?)\s*}}/s){
        return 0 if $1 eq 'all';
        my @opt = split(/\s*,\s*/, $1);
        return (grep $_ eq $opt, @opt) ? 0 : 1;
    }
    return 1;
}

VB.NET[عدل]

Public Shared Function AllowBots(ByVal text As String, ByVal user As String) As Boolean
    Return Not Regex.IsMatch(text, "\{\{(nobots|bots\|(allow=none|deny=(?!none).*(" & user.Normalize() & "|all)|optout=all))\}\}", RegexOptions.IgnoreCase)
End Function

C#[عدل]

public static bool AllowBots(string text, string user)
{
    return !Regex.IsMatch(text, @"\{\{(nobots|bots\|(allow=none|deny=(?!none).*(" + user.Normalize() + @".*|all)|optout=all))\}\}", RegexOptions.IgnoreCase);
}

Java[عدل]

public static boolean allowBots(String text, String user)
{
      return !text.matches("(?si).*\\{\\{(nobots|bots\\|(allow=none|deny=([^\\}]*?" + user + "[^\\}]*?|all)|optout=all))\\}\\}.*");
}

JavaScript[عدل]

function allowBots(text, user){
  if (!new RegExp("\\{\\{\\s*(nobots|bots[^}]*)\\s*\\}\\}", "i").test(text)) return true;
  return (new RegExp("\\{\\{\\s*bots\\s*\\|\\s*deny\\s*=\\s*([^}]*,\\s*)*" + user.replace(/([\(\)\*\+\?\.\-\:\!\=\/\^\$])/g, "\\$1") + "\\s*(?=[,\\}])[^}]*\\s*\\}\\}", "i").test(text)) ? false : new RegExp("\\{\\{\\s*((?!nobots)|bots(\\s*\\|\\s*allow\\s*=\\s*((?!none)|([^}]*,\\s*)*" + user.replace(/([\(\)\*\+\?\.\-\:\!\=\/\^\$])/g, "\\$1") + "\\s*(?=[,\\}])[^}]*|all))?|bots\\s*\\|\\s*deny\\s*=\\s*(?!all)[^}]*|bots\\s*\\|\\s*optout=(?!all)[^}]*)\\s*\\}\\}", "i").test(text);
}

Python[عدل]

This code assumes that the mwparserfromhell library was installed and imported in the current script.

def allow_bots(text, user):
	user = user.lower().strip()
	text = mwparserfromhell.parse(text)
	for tl in text.filter_templates():
		if tl.name.matches(['bots', 'nobots']):
			break
	else:
		return True
	for param in tl.params:
		bots = [x.lower().strip() for x in param.value.split(",")]
		if param.name == 'allow':
			if ''.join(bots) == 'none': return False
			for bot in bots:
				if bot in (user, 'all'):
					return True
		elif param.name == 'deny':
			if ''.join(bots) == 'none': return True
			for bot in bots:
				if bot in (user, 'all'):
					return False
	if (tl.name.matches('nobots') and len(tl.params) == 0):
		return False
	return True

انظر أيضًا[عدل]