用户:Hehuabot/AutoArchive:修订间差异

来自Postal Wiki
创建页面,内容为“这个机器人运行Pywikibot代码,可以根据你的设置自动将你的用户讨论页存档,机器人的存档操作'''不会'''触发新消息提示。机器人每天自动运行一次此程序,所以设置好之后请不要着急。 以下用法仅供参考,实际用法以官方说明mediawikiwiki:Manual:Pywikibot/archivebot.py/setup为准。 [https://zh.wikipedia.org/wiki/Special:WhatLinksHere?target=Use…”
 
无编辑摘要
第11行: 第11行:


<pre style="overflow: auto">
<pre style="overflow: auto">
{{User:Wcam/ArchiveConfig
{{User:Hehua/ArchiveConfig
| algo    = old(...)
| algo    = old(...)
| archive = 存档所在页面
| archive = 存档所在页面
第18行: 第18行:
</pre>
</pre>
<!--
<!--
Well, maybe '''not exactly''' that (read about required options below), but that's how it's done. By the way, [[User:Wcam/ArchiveConfig|the template]] has '''no content''' and is sysop-'''protected''', so don't worry about visual appearance. :)
Well, maybe '''not exactly''' that (read about required options below), but that's how it's done. By the way, [[User:Hehua/ArchiveConfig|the template]] has '''no content''' and is sysop-'''protected''', so don't worry about visual appearance. :)


The bot expects to see only one parameter per line. The closing }} must be on its own line. There must be no leading spaces before the pipes. If you drop out the newlines used in the above example, e.g. by wrapping the template invocation onto a single line, the bot may not do what you expect.
The bot expects to see only one parameter per line. The closing }} must be on its own line. There must be no leading spaces before the pipes. If you drop out the newlines used in the above example, e.g. by wrapping the template invocation onto a single line, the bot may not do what you expect.
第34行: 第34行:


<pre style="overflow: auto">
<pre style="overflow: auto">
{{User:Wcam/ArchiveConfig
{{User:Hehua/ArchiveConfig
| algo    = old(7d)
| algo    = old(7d)
| archive = User talk:Example/存档
| archive = User talk:Example/存档
第44行: 第44行:
==== 例子二:自动增加存档页 ====
==== 例子二:自动增加存档页 ====
<pre style="overflow: auto">
<pre style="overflow: auto">
{{User:Wcam/ArchiveConfig
{{User:Hehua/ArchiveConfig
| algo                = old(31d)
| algo                = old(31d)
| archive            = User talk:Example/存档%(counter)d
| archive            = User talk:Example/存档%(counter)d
第61行: 第61行:


<pre style="overflow: auto">
<pre style="overflow: auto">
{{User:Wcam/ArchiveConfig
{{User:Hehua/ArchiveConfig
| algo    = old(5d)
| algo    = old(5d)
| archive = User talk:Example/存档/%(year)d年/%(month)s月
| archive = User talk:Example/存档/%(year)d年/%(month)s月
第71行: 第71行:
=== 参数解释 ===
=== 参数解释 ===
<pre>
<pre>
{{User:Wcam/ArchiveConfig  
{{User:Hehua/ArchiveConfig  
| archive            =  
| archive            =  
| algo                =  
| algo                =  

2026年6月2日 (二) 09:02的版本

这个机器人运行Pywikibot代码,可以根据你的设置自动将你的用户讨论页存档,机器人的存档操作不会触发新消息提示。机器人每天自动运行一次此程序,所以设置好之后请不要着急。

以下用法仅供参考,实际用法以官方说明mediawikiwiki:Manual:Pywikibot/archivebot.py/setup为准。

查看使用本功能的用户

存档设置

请把以下的设置模板放在页面的最顶部,不可以放在子页面中。每行只填写一个参数,即每个分隔符(|)应另起一行,最后的「}}」应独占一行:

警告: 请不要直接复制下方的几行代码,这只是解释用途,并不能正常使用。

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

例子

以下所有例子中,请把“User talk:Example”改成你的用户讨论页!
如果仍然不能正常工作,请阅读下方minthreadsleft和minthreadstoarchive参数的介绍。

例子一:固定存档页

警告: 尽管这是最简单的,但可能不是最好的选择,第二个例子更加常用

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

这样的话机器人会把User talk:Example中7天以前的讨论存档至User talk:Example/存档。注意这个存档会一直增长,很有可能变得难以打开。

例子二:自动增加存档页

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

这告诉机器人存档超过31天(留下最近的四个)的讨论,从User talk:Example存档至User talk:Example/存档1,直到它的长度超过70K。这时,机器人会自动新建第二个存档页,并更新设置中的counter参数。请注意要设置一个maxarchivesize参数,否则会像第一种情况一样。此外,每个存档页顶部会加上{{talkarchive}}模板,你也可以选择其他模板。

例子三:按日期存档

警告: 不要将下面的year等变量替换成实际的数值。

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

这样设置以后,超过5天的讨论会按月存档。例如2013年2月的讨论会存档至User talk:Example/存档/2013年/2月。

参数解释

{{User:Hehua/ArchiveConfig 
| archive             = 
| algo                = 
| counter             = 
| maxarchivesize      = 
| minthreadsleft      = 
| minthreadstoarchive = 
| archiveheader       = 
| key                 = 
}}
参数 介绍
archive 存档页的名称。这个参数支持使用变量,可以由机器人根据变量的值(比如月份)来建立存档页。请注意不要加入模板或魔术字之类的东西。除非机器人的操作者给你提供了一个key(见下方),存档页必须是被存档页面的子页面。
algo 决定机器人是否存档一个讨论的算法。目前只有一种形式:old(...),其中...表示一个讨论若多久没有新留言则会被存档(例如:24h、72h、5d、21d等等)
counter 存档页数的计数器。如果archive参数没有使用变量%(counter)d,那么这个参数会被忽略。如果你现在已有存档页,请把它设为当前的存档页数目。Wcam-bot在需要时会自动更新这个数值。
maxarchivesize 存档页的最大长度。如果没有使用%(counter)d则会被忽略。这个参数有两种形式:#K和#T。例如maxarchivesize=256K表示最大长度为256KB,maxarchivesize=100T表示最大长度为100个讨论(无论字节数为多少)。
minthreadsleft 页面上最少留下的讨论数目(防止页面被清空),默认值为5。
minthreadstoarchive 每次存档的讨论数目的最小值,用于降低编辑频率。Wcam-bot在可存档讨论数目低于此数值时不会进行存档,默认值为2。
archiveheader 加在存档页顶部的内容。这个参数支持使用变量。注意这个参数不能使用多行文字。你可以在存档页顶部加上你的存档索引,默认值为{{talk archive}}。
key 将页面内容存档至子页面以外的地方需要本参数,以尽量避免恶作剧、破坏。

变量

变量 意义
%(counter)d counter的当前数值
%(year)d 待存档讨论的年份
%(month)d 待存档讨论的月份
%(quarter)d 待存档讨论的季度(1-4)
%(monthname)s 英文月份名称,中文版不需要
%(monthnameshort)s 英文月份简称,中文版不需要