Ҡалып:Bots/doc: өлгөләр араһындағы айырма

Эстәлек юйылған Эстәлек өҫтәлгән
"С помощью этого шаблона можно сообщить боту, что он не должен трогать страницу…" исемле яңы бит булдырылған
 
Xqbot (фекер алышыу | өлөш)
ә Bot: Replace deprecated <source> tag and "enclose" parameter [https://lists.wikimedia.org/pipermail/wikitech-ambassadors/2020-April/002284.html]
 
65 юл:
 
=== PHP ===
<sourcesyntaxhighlight lang="php">
function allowBots( $text ) {
global $user;
71 юл:
return true;
}
</syntaxhighlight>
</source>
 
=== Perl ===
 
<sourcesyntaxhighlight lang="perl">
sub allowBots {
my($text, $user, $opt) = @_;
99 юл:
return 1;
}
</syntaxhighlight>
</source>
 
=== C# ===
<sourcesyntaxhighlight lang="csharp">
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>
</source>
 
 
==== VB.NET ====
<sourcesyntaxhighlight lang="vbnet">
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>
</source>
 
=== Java ===
<sourcesyntaxhighlight lang="java">
public static boolean allowBots(String text, String user)
{
return !text.matches("(?si).*\\{\\{(nobots|bots\\|(allow=none|deny=(.*?" + user + ".*?|all)|optout=all))\\}\\}.*");
}
</syntaxhighlight>
</source>
 
=== JavaScript ===
<sourcesyntaxhighlight lang="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>
</source>
 
=== Python ===
{{see also|mw:Pywikipediabot}}
<sourcesyntaxhighlight lang="python">
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>
</source>
 
== См. также ==
«https://ba.wikipedia.org/wiki/Ҡалып:Bots/doc» битенән алынған