Templat:Bots/doc: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Tidak ada ringkasan suntingan
HsfBot (bicara | kontrib)
 
Baris 103:
==== Perl ====
 
<sourcesyntaxhighlight lang="perl">
sub allow_bots {
my($text, $user, $opt) = @_;
Baris 127:
return 1;
}
</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>
 
==== C# ====
<sourcesyntaxhighlight lang="csharp">
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);
}
</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 ====
Baris 162:
==== Python ====
This code assumes that the [http://pypi.python.org/pypi/mwparserfromhell/ mwparserfromhell] library was installed and imported in the current script.
<sourcesyntaxhighlight lang="python">
def allow_bots(text, user):
user = user.lower().strip()
Baris 186:
return False
return True
</syntaxhighlight>
</source>
 
==See also==