浏览代码

Write afc_dailycats task.

pull/15/head
Ben Kurtovic 11 年前
父节点
当前提交
6386855cd5
共有 1 个文件被更改,包括 27 次插入2 次删除
  1. +27
    -2
      tasks/afc_dailycats.py

+ 27
- 2
tasks/afc_dailycats.py 查看文件

@@ -20,6 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from datetime import datetime, timedelta

from earwigbot.tasks import Task

class AFCDailyCats(Task):
@@ -28,7 +30,30 @@ class AFCDailyCats(Task):
number = 3

def setup(self):
pass
cfg = self.config.tasks.get(self.name, {})
self.prefix = cfg.get("prefix", "Category:AfC submissions by date/")
self.content = cfg.get("content", "{{AFC submission category header}}")
default_summary = "Creating {0} category page for [[WP:AFC|Articles for creation]]."
self.summary = self.make_summary(cfg.get("summary", default_summary))

def run(self, **kwargs):
pass
if self.shutoff_enabled():
return
self.site = self.bot.wiki.get_site()
self.make_cats()
self.make_cats(1)
self.make_cats(2)
self.make_cats(3)

def make_cats(self, days=0):
dt = datetime.now() + timedelta(days)
self.make_cat(dt.strftime("%d %B %Y"), "daily")
if dt.day == 1:
self.make_cat(dt.strftime("%B %Y"), "monthly")
if dt.month == 1:
self.make_cat(dt.strftime("%Y"), "yearly")

def make_cat(self, suffix, word):
page = self.site.get_page(self.prefix + suffix)
if page.exists() == page.PAGE_MISSING:
page.edit(self.content, self.summary.format(word))

正在加载...
取消
保存