diff --git a/delojza.py b/delojza.py index 1a86dbb..5acbe8d 100755 --- a/delojza.py +++ b/delojza.py @@ -489,6 +489,10 @@ class DelojzaBot: os.listdir(self.out_dir)))) 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() 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] @@ -527,6 +531,10 @@ class DelojzaBot: return sorted(result, key=itemgetter(0)) 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() if len(orphans) == 0: update.message.reply_text("Good job, no orphan tags!") @@ -535,6 +543,10 @@ class DelojzaBot: ", ".join(map(itemgetter(0), orphans))) 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() if len(orphans) == 0: update.message.reply_text("Good job, no orphan tags!")