User: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.