limit /orphan and /stats cmds to protected chats to curb trolling
This commit is contained in:
parent
a5c1b724ab
commit
49cdb48bba
1 changed files with 12 additions and 0 deletions
12
delojza.py
12
delojza.py
|
@ -489,6 +489,10 @@ class DelojzaBot:
|
||||||
os.listdir(self.out_dir))))
|
os.listdir(self.out_dir))))
|
||||||
|
|
||||||
def tg_stats(self, _, update):
|
def tg_stats(self, _, update):
|
||||||
|
self.db.initialize()
|
||||||
|
if update.message.chat.id not in self.db.get_protected_chats():
|
||||||
|
update.message.reply_text((self.markov.make_sentence() + "!") if self.markov and random() > .7 else "nope.")
|
||||||
|
return
|
||||||
tag_dirs = self._get_tag_dirs()
|
tag_dirs = self._get_tag_dirs()
|
||||||
reply = "Total number of tags: {}\n\n".format(len(tag_dirs))
|
reply = "Total number of tags: {}\n\n".format(len(tag_dirs))
|
||||||
counts = [(directory, os.listdir(os.path.join(self.out_dir, directory))) for directory in tag_dirs]
|
counts = [(directory, os.listdir(os.path.join(self.out_dir, directory))) for directory in tag_dirs]
|
||||||
|
@ -527,6 +531,10 @@ class DelojzaBot:
|
||||||
return sorted(result, key=itemgetter(0))
|
return sorted(result, key=itemgetter(0))
|
||||||
|
|
||||||
def tg_orphan(self, _, update):
|
def tg_orphan(self, _, update):
|
||||||
|
self.db.initialize()
|
||||||
|
if update.message.chat.id not in self.db.get_protected_chats():
|
||||||
|
update.message.reply_text((self.markov.make_sentence() + "!") if self.markov and random() > .7 else "nope.")
|
||||||
|
return
|
||||||
orphans = self._get_orphan_tags()
|
orphans = self._get_orphan_tags()
|
||||||
if len(orphans) == 0:
|
if len(orphans) == 0:
|
||||||
update.message.reply_text("Good job, no orphan tags!")
|
update.message.reply_text("Good job, no orphan tags!")
|
||||||
|
@ -535,6 +543,10 @@ class DelojzaBot:
|
||||||
", ".join(map(itemgetter(0), orphans)))
|
", ".join(map(itemgetter(0), orphans)))
|
||||||
|
|
||||||
def tg_orphan_full(self, _, update):
|
def tg_orphan_full(self, _, update):
|
||||||
|
self.db.initialize()
|
||||||
|
if update.message.chat.id not in self.db.get_protected_chats():
|
||||||
|
update.message.reply_text((self.markov.make_sentence() + "!") if self.markov and random() > .7 else "nope.")
|
||||||
|
return
|
||||||
orphans = self._get_orphan_tags()
|
orphans = self._get_orphan_tags()
|
||||||
if len(orphans) == 0:
|
if len(orphans) == 0:
|
||||||
update.message.reply_text("Good job, no orphan tags!")
|
update.message.reply_text("Good job, no orphan tags!")
|
||||||
|
|
Loading…
Reference in a new issue