For faster navigation, this Iframe is preloading the Wikiwand page for Template:Bots.

Template:Bots

文档图示 模板文档[查看] [编辑] [历史] [清除缓存]

此頁面是為用戶解釋有關於如何允許或排除機器人對頁面的瀏覽訪問並留下訊息,相關的指令非常容易理解,因下有範例在此不贅述。這類模板適用於用戶頁或其討論頁當中(即以「User:」或「User_talk:」這2個命名空间開首的頁面),在用戶空間之外請小心使用,以避免阻止有用的機器人編輯。對於機械人管理者,建議閣下遵從頁面中((bots))及((nobots))的指示。

用戶須意識到透過選擇排除來自機器人的通知,根據他們所選擇的標籤,機器人將不會被通知有關他們已編輯或上傳資料的訊息(如版權問題、條目DYK等訊息)。

對於百科條目空間,尤其注意:

  • 小心模板作用範圍過大,帶來副作用;
  • 應用於處置機器人持有者或機器人社群的根本問題;
  • 一旦相關問題解決,請移除模板標籤。

機器人語法

  • ((nobots)) 封鎖所有的機器人帳戶訪問
  • ((bots)) 允許所有機器人帳戶訪問
  • ((bots|allow=<botlist>)) 封鎖所有列表指定之外的機器人帳戶
  • ((bots|deny=<botlist>)) 封鎖列表指定之所有機器人帳戶

以下指令使用於過濾指定用戶名的機器人帳戶(以半形逗號作間隔),另關鍵字“AWB”可以過濾所有使用維基自動瀏覽器的機器人:

  • ((bots|allow=HagermanBot,Werdnabot))
  • ((bots|deny=AWB))

<botlist> 可以透過 "none" or "all" 選項允許/封鎖機器人訪問,如下:

  • ((bots|allow=all)) 允許所有機器人帳戶訪問
  • ((bots|allow=none)) 封鎖所有的機器人帳戶訪問
  • ((bots|deny=all)) 封鎖所有的機器人帳戶訪問
  • ((bots|deny=none)) 允許所有機器人帳戶訪問

但須注意的是,由於機器人在它們創建時不是為了不通知用戶,因此并非所有机器人会遵守以上标签,这取决于机器人程序的相关设定。

排除所有機器人通知

另外一種排除通知法是按通知種類而過濾,當用戶套用至個人用戶頁面時,相關類型的停滯將會被過濾,當用戶套用以下模板就代表其同意本模板使用原則。但如果用在非其個人用戶頁面放置以下模板將會被視為破壞

使用這種選擇性排除的方法,用戶將不會受到來自機器人的負面通知,但透過人工編輯的負面通知/警告將在排除範圍之外。

  • ((bots|optout=all)) 過濾所有機器人所發出的所有通知(更多選項請參考以下列表)
  • ((bots|optout=nosource)) 過濾所有機器人所發出有關上傳資料缺乏來源的通知
  • ((bots|optout=nolicense)) 過濾所有機器人所發出有關上傳資料缺乏授權的通知
  • ((bots|optout=orfud)) 過濾所有機器人所發出有關上傳合理使用資料缺乏使用的通知
  • ((bots|optout=norationale)) 過濾所有機器人所發出有關上傳資料合理使用原因的通知
  • ((bots|optout=replaceable)) 過濾所有機器人所發出有關上傳資料不符合合理使用標準的通知
  • ((bots|optout=bettersource)) 過濾所有機器人所發出有關上傳資料被要求更佳來源的通知
  • ((bots|optout=afd)) 過濾所有機器人所發出有關新條目被提名刪除或其他條目/表格的通知
  • ((bots|optout=ifd)) 過濾所有機器人所發出有關上傳圖像被提名刪除或其他資料(如音影像)的通知
  • ((bots|optout=prod)) 過濾所有機器人所發出有關上傳資料被納入刪除候選或類似的通知


以上選項可透過逗號間隔相加使用,例如:

  • ((bots|optout=nosource,nolicense)) 過濾所有機器人所發出有關上傳資料缺乏來源以及缺乏授權的通知
  • ((bots|optout=orfud,norationale,replaceable)) 過濾所有機器人所發出有關上傳資料合理使用的通知

限制

有些通知不能以此模板排除,此類通知包括但不限於:

  1. 違反版權的通知
  2. 破壞(及類似行為)的通知
  3. 任何不含上方標籤的通知(有任何被遺忘的通知標籤?請於討論頁告訴我們。;])

置入使用

  • Pywikipediabot於r4096後支持((bots))及((nobots)),然而可用參數將其忽略。
  • 自動維基瀏覽器由3.2.0.0起完全支持((bots))及((nobots))。另外,將用戶名設置為awb可以拒絕所有自動維基瀏覽器機械人。自動維基瀏覽器亦有選項可忽略這些模板。

範例

PHP

function allowBots( $text ) {
    global $user;
    if (preg_match('/\{\{(nobots|bots\|allow=none|bots\|deny=all|bots\|optout=all|bots\|deny=.*?'.preg_quote($user,'/').'.*?)\}\}/iS',$text)) { return false; }
    return true;
}

Perl

sub allowBots {
    my($text, $user, $opt) = @_;
    return 0 if $text =~ /((nob[o]ts))/;
    return 1 if $text =~ /((b[o]ts))/;
    if($text =~ /((bots\s*\|\s*allow\s*=\s*(.*?)\s*))/s){
        return 1 if $1 eq 'all';
        return 0 if $1 eq 'none';
        my @bots = split(/\s*,\s*/, $1);
        return (grep $_ eq $user, @bots)?1:0;
    }
    if($text =~ /((bots\s*\|\s*deny\s*=\s*(.*?)\s*))/s){
        return 0 if $1 eq 'all';
        return 1 if $1 eq 'none';
        my @bots = split(/\s*,\s*/, $1);
        return (grep $_ eq $user, @bots)?0:1;
    }
    if(defined($opt) && $text =~ /((bots\s*\|\s*optout\s*=\s*(.*?)\s*))/s){
        return 0 if $1 eq 'all';
        my @opt = split(/\s*,\s*/, $1);
        return (grep $_ eq $opt, @opt)?0:1;
    }
    return 1;
}

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);
}

Java

public static boolean AllowBots(String text, String user)
{
      return !Regex.Match(text, "\\{\\{(nobots|bots\\|(allow=none|deny=(.*?" + user.Normalize() + ".*?|all)|optout=all))\\}\\}", RegexOptions.IgnoreCase).Success;
}

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);
}

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

參見

{{bottomLinkPreText}} {{bottomLinkText}}
Template:Bots
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?