def task(self):
     the_bot_it_user = User(self.wiki, "Benutzer:THEbotIT")
     page: Optional[Page] = None
     for idx, (page, revision_id, ts, _) in enumerate(
             the_bot_it_user.contributions(total=10000,
                                           start=Timestamp(year=2022,
                                                           month=3,
                                                           day=26),
                                           end=Timestamp(year=2022,
                                                         month=3,
                                                         day=22))):
         if idx % 100 == 0:
             self.logger.info(f"index is {idx}")
         if idx < 700:
             continue
         last_two_reivisions: List[Revision] = list(page.revisions())[:2]
         # make sure the last edit is the potential dangerous one
         if last_two_reivisions[0]["revid"] == revision_id:
             if last_two_reivisions[0]["size"] - last_two_reivisions[1][
                     "size"] < 0:
                 if "RE:" in page.title():
                     self.logger.info(f"bad edit on {page.title()}")
                     page.text = page.getOldVersion(
                         oldid=last_two_reivisions[1]["revid"])
                     page.save(
                         f"Änderung {last_two_reivisions[0]['revid']} von [[Benutzer:THEbotIT|THEbotIT]] ([[Benutzer Diskussion:THEbotIT|Diskussion]]) rückgängig gemacht."
                     )
     self.logger.info("THE END")
Beispiel #2
0
 def test_short_mediawiki_format(self):
     """Test short mw timestamp conversion from and to Timestamp format."""
     t1 = Timestamp(2018, 12, 17)
     t2 = Timestamp.fromtimestampformat('20181217')  # short timestamp
     ts1 = t1.totimestampformat()
     ts2 = t2.totimestampformat()
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
Beispiel #3
0
def convert_date(value):
    if not value:
        return None
    return Timestamp(value.year, value.month, value.day, value.hour,
                     value.minute, value.second)
Beispiel #4
0
def reduce_seconds(value):
    if not value:
        return None
    return Timestamp(value.year, value.month, value.day,
                     value.hour, value.minute)