Templat:Bots/doc: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
Tidak ada ringkasan suntingan |
k Bot: fixed → pages using deprecated source tags |
||
Baris 103:
==== Perl ====
<
sub allow_bots {
my($text, $user, $opt) = @_;
Baris 127:
return 1;
}
</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>
==== 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);
}
</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 ====
Baris 162:
==== Python ====
This code assumes that the [http://pypi.python.org/pypi/mwparserfromhell/ mwparserfromhell] library was installed and imported in the current script.
<
def allow_bots(text, user):
user = user.lower().strip()
Baris 186:
return False
return True
</syntaxhighlight>
==See also==
|