Ҡалып:Bots/doc: өлгөләр араһындағы айырма
Эстәлек юйылған Эстәлек өҫтәлгән
Ардах18 (фекер алышыу | өлөш) "С помощью этого шаблона можно сообщить боту, что он не должен трогать страницу…" исемле яңы бит булдырылған |
Xqbot (фекер алышыу | өлөш) ә Bot: Replace deprecated <source> tag and "enclose" parameter [https://lists.wikimedia.org/pipermail/wikitech-ambassadors/2020-April/002284.html] |
||
65 юл:
=== PHP ===
<
function allowBots( $text ) {
global $user;
71 юл:
return true;
}
</syntaxhighlight>
=== Perl ===
<
sub allowBots {
my($text, $user, $opt) = @_;
99 юл:
return 1;
}
</syntaxhighlight>
=== C# ===
<
public static bool AllowBots(string text, string user)
{
return !Regex.Match(text, @"\{\{(nobots|bots\|(allow=none|deny=.*?" + user.Normalize() + @".*?|optout=all|deny=all))\}\}", RegexOptions.IgnoreCase).Success;
}
</syntaxhighlight>
==== 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
</syntaxhighlight>
=== Java ===
<
public static boolean allowBots(String text, String user)
{
return !text.matches("(?si).*\\{\\{(nobots|bots\\|(allow=none|deny=(.*?" + user + ".*?|all)|optout=all))\\}\\}.*");
}
</syntaxhighlight>
=== 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+"\\s*(?=[,\\}])[^}]*\\s*\\}\\}", "i").test(text)) ? false : new RegExp("\\{\\{\\s*((?!nobots)|bots(\\s*\\|\\s*allow\\s*=\\s*((?!none)|([^}]*,\\s*)*"+user+"\\s*(?=[,\\}])[^}]*|all))?|bots\\s*\\|\\s*deny\\s*=\\s*(?!all)[^}]*|bots\\s*\\|\\s*optout=(?!all)[^}]*)\\s*\\}\\}", "i").test(text);
}
</syntaxhighlight>
=== Python ===
{{see also|mw:Pywikipediabot}}
<
def Allowbots(text, user):
if (re.search(r'\{\{(nobots|bots\|(allow=none|deny=.*?' + user + r'.*?|optout=all|deny=all))\}\}', text)):
return false
return true
</syntaxhighlight>
== См. также ==
|