|
@@ -20,6 +20,8 @@ |
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
|
# SOFTWARE. |
|
|
# SOFTWARE. |
|
|
|
|
|
|
|
|
|
|
|
from datetime import datetime, timedelta |
|
|
|
|
|
|
|
|
from earwigbot.tasks import Task |
|
|
from earwigbot.tasks import Task |
|
|
|
|
|
|
|
|
class AFCDailyCats(Task): |
|
|
class AFCDailyCats(Task): |
|
@@ -28,7 +30,30 @@ class AFCDailyCats(Task): |
|
|
number = 3 |
|
|
number = 3 |
|
|
|
|
|
|
|
|
def setup(self): |
|
|
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): |
|
|
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)) |