使用者:Makecat-bot/自動存檔

維基百科,自由的百科全書


這個機器人可以根據你的設置自動將你的用戶討論頁存檔,機器人的存檔操作不會觸發新消息提示。機器人每天自動運行一次此程序,所以設置好之後請不要着急。

存檔設置[編輯]

請把以下的設置模板放在頁面的頂部,至少是在第一個章節之前,並且不可以放在子頁面中:

{{User:Makecat-bot/ArchiveConfig
| algo    = old(...)
| archive = 存档所在页面
[其他参数 - ***请先阅读下文***]
}}

例子[編輯]

請把「User talk:Example」改成你的用戶討論頁!
如果仍然不能正常工作,請閱讀下方minthreadsleftminthreadstoarchive參數的介紹。

例子一:固定存檔頁[編輯]

{{User:Makecat-bot/ArchiveConfig
| algo    = old(7d)
| archive = User talk:Example/存档
}}

這樣的話機器人會把User talk:Example中7天以前的討論存檔至User talk:Example/存檔。注意這個存檔會一直增長,很有可能變得難以打開。

例子二:自動增加存檔頁[編輯]

{{User:Makecat-bot/ArchiveConfig
| algo                = old(31d)
| archive             = User talk:Example/存档%(counter)d
| counter             = 1
| maxarchivesize      = 70K
| archiveheader       = {{talkarchive}}
| minthreadstoarchive = 1
| minthreadsleft      = 4
}}

這告訴機器人存檔超過一個月(留下最近的四個)的討論,從User talk:Example存檔至User talk:Example/存檔1,直到它的長度超過70K。這時,機器人會自動新建第二個存檔頁,並更新設置中的counter參數。請注意要設置一個maxarchivesize參數,否則會像第一種情況一樣。此外,每個存檔頁頂部會加上{{talkarchive}}模板,你也可以選擇其他模板。

例子三:按日期存檔[編輯]

{{User:Makecat-bot/ArchiveConfig
| algo    = old(5d)
| archive = User talk:Example/存档/%(year)d年/%(month)s月
}}

這樣設置以後,超過5天的討論會按月存檔。例如2013年2月的討論會存檔至User talk:Example/存檔/2013年/2月

參數解釋[編輯]

{{User:Makecat-bot/ArchiveConfig 
| archive             = 
| algo                = 
| counter             = 
| maxarchivesize      = 
| minthreadsleft      = 
| minthreadstoarchive = 
| archiveheader       = 
| key                 = 
}}
參數 介紹
archive 存檔頁的名稱。這個參數支持使用變量,可以由機器人根據變量的值(比如月份)來建立存檔頁。請注意不要加入模板或魔術字之類的東西。除非機器人的操作者給你提供了一個key(見下方),存檔頁必須是被存檔頁面的子頁面。
algo 決定機器人是否存檔一個討論的算法。目前只有一種形式:old(...),其中...表示一個討論若多久沒有新留言則會被存檔(例如:24h72h5d21d等等)
counter 存檔頁數的計數器。如果archive參數沒有使用變量%(counter)d,那麼這個參數會被忽略。如果你現在已有存檔頁,請把它設為當前的存檔頁數目。Makecat-bot在需要時會自動更新這個數值。
maxarchivesize 存檔頁的最大長度。如果沒有使用%(counter)d則會被忽略。這個參數有兩種形式:#K和#T。例如maxarchivesize=256K表示最大長度為256KB,maxarchivesize=100T表示最大長度為100個討論(無論字節數為多少)。
minthreadsleft 頁面上最少留下的討論數目(防止頁面被清空),默認值為5。
minthreadstoarchive 每次存檔的討論數目的最小值,用於降低編輯頻率。Makecat-bot在可存檔討論數目低於此數值時不會進行存檔,默認值為2。
archiveheader 加在存檔頁頂部的內容。這個參數支持使用變量。注意這個參數不能使用多行文字。你可以在存檔頁頂部加上你的存檔索引,默認值為{{talk archive}}。
key 將頁面內容存檔至子頁面以外的地方需要本參數,以儘量避免惡作劇、破壞。如果你有合適的理由,請聯繫我

變量[編輯]

變量 意義
%(counter)d counter的當前數值
%(year)d 待存檔討論的年份
%(month)d 待存檔討論的月份
%(monthname)s 英文月份名稱,中文版不需要
%(monthnameshort)s 英文月份簡稱,中文版不需要

Those python-savvy people will immediately recognize these variables are filled at runtime with the % operator and should know how to adjust the format. A few points of interest to others:

  • make sure you don't mess up the last letter after the brackets (it's "d" for integers and "s" for strings)
  • integer variables may be left-padded with zeros:
    %(counter)03d evaluates to 013 if the counter's value equals 13,
    %(month)02d becomes 05 for May etc.

After you have set up archiving[編輯]

The bot runs once a day at a preset hour, or twice a day for WP:AN and WP:AN/I. Simply wait for the next cycle and you should see the bot's entries in the history list of your article providing there was anything to archive, and the history list entry should provide a link to the archive page you specified.

Various templates will produce an automatic list of archive subpages. Typically, such a template will be added to the top-level talk page to make archives easier to find. Simply add the template name in {{curly-braces}} where you want it to appear. Popular templates used for this purpose include:

Delaying or preventing archiving of particular threads[編輯]

Archiving can be delayed for a particular thread by substituting the template {{DNAU}} into the thread. Use {{subst:DNAU}} to retain a thread indefinitely, or {{subst:DNAU|<integer>}} to retain a thread for <integer> days. see the template documentation for details about its use and function.