Templat:Bots/doc: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Tidak ada ringkasan suntingan
HsfBot (bicara | kontrib)
 
(Satu revisi perantara oleh satu pengguna lainnya tidak ditampilkan)
Baris 1:
{{documentation subpage}}
{{High-use|5.800.00029}}
<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->
{{Lua|Module:String}}
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==