diff --git a/README.md b/README.md index d55ac30..15f4348 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,7 @@ Demanar-ho al bot, mencionant-lo: @bot alta @bot baixa +També es poden esborrar tots els missatges que el bot tingui d'un usuari concret. Només cal fer: + +@bot esborra + diff --git a/corpus.py b/corpus.py index e59a020..9b3f69a 100644 --- a/corpus.py +++ b/corpus.py @@ -94,6 +94,29 @@ if __name__ == '__main__': bot.mastodon.status_post(f'@{mention.acct}, error al esborrar.', in_reply_to_id=mention.status_id, visibility='direct') + elif mention.question == "esborra": + + found_it = db.check_user(mention.acct) + + if not found_it: + + bot.mastodon.status_post(f"@{mention.acct} no estàs donat d'alta", in_reply_to_id=mention.status_id, visibility='direct') + + else: + + are_deleted = db.del_user_posts(mention.acct) + + if are_deleted: + + post = f"@{mention.acct} tots els teus tus esborrats amb èxit!\n\n" + + bot.mastodon.status_post(post, in_reply_to_id=mention.status_id, visibility='direct') + + else: + + bot.mastodon.status_post(f'@{mention.acct}, error al esborrar tots els tuts.', in_reply_to_id=mention.status_id, visibility='direct') + + print(f"Dismissing notification id {mention.id}") bot.mastodon.notifications_dismiss(mention.id) diff --git a/mastodonbot.py b/mastodonbot.py index a7941bc..cdf97be 100644 --- a/mastodonbot.py +++ b/mastodonbot.py @@ -307,7 +307,7 @@ class Mastodonbot: keyword = question - if keyword == 'alta' or keyword == 'baixa': + if keyword == 'alta' or keyword == 'baixa' or keyword == 'esborra': keyword_length = len(keyword)