Example #1
0
 def send_phrase(self, msg, audio_id):
     if 0 <= audio_id < len(self.dataset.data_keys):
         audio, duration = self.dataset.get_phrase(audio_id)
         logger.info("%s: sending phrase #%d to user %s" % (msg.text, audio_id, user_log_string(msg)))
         self.send_audio(msg.chat.id, audio, duration)
     else:
         bot.send_random_phrase(msg)
Example #2
0
 def audio_list(self, msg):
     logger.info("%s: sending phrase list to user %s" %
                 (msg.text, user_log_string(msg)))
     text = ["Phrase list (use '/say ID' to choose phrase):"]
     for i, title in self.dataset.list_files():
         text.append("*[%2d]*  _%s_" % (i, title))
     self.reply_to(msg, "\n".join(text), parse_mode="Markdown")
Example #3
0
 def top_phrases(self, msg):
     logger.info("%s: sending top phrases to user %s" % (msg.text, user_log_string(msg)))
     lines = ["Top phrases (use '/say ID' to choose phrase):"]
     for audio_id, count in self.dataset.top_phrases.most_common(5):
         lines.append(
             "*[%2d]*  _%s_ (%d reproductions)" % (audio_id, self.dataset.get_audio_data(audio_id)['title'], count))
     self.reply_to(msg, "\n".join(lines), parse_mode="Markdown")
Example #4
0
 def search_mentions(self, msg):
     msg_plain = sanitize_string(msg.text)
     msg_words = set(msg_plain.split())
     if not self.mention_words.intersection(msg_words):
         return
     logger.info("mention: responding to user %s" % user_log_string(msg))
     audio, duration = self.dataset.random_phrase(msg_words)
     self.send_audio(msg.chat.id, audio, duration)
Example #5
0
 def search_mentions(self, msg):
     msg_plain = sanitize_string(msg.text)
     msg_words = set(msg_plain.split())
     if not self.mention_words.intersection(msg_words):
         return
     logger.info("mention: responding to user %s" % user_log_string(msg))
     audio, duration = self.dataset.random_phrase(msg_words)
     self.send_audio(msg.chat.id, audio, duration)
Example #6
0
 def send_phrase(self, msg, audio_id):
     if 0 <= audio_id < len(self.dataset.data_keys):
         audio, duration = self.dataset.get_phrase(audio_id)
         logger.info("%s: sending phrase #%d to user %s" %
                     (msg.text, audio_id, user_log_string(msg)))
         self.send_audio(msg.chat.id, audio, duration)
     else:
         bot.send_random_phrase(msg)
Example #7
0
 def top_phrases(self, msg):
     logger.info("%s: sending top phrases to user %s" %
                 (msg.text, user_log_string(msg)))
     lines = ["Top phrases (use '/say ID' to choose phrase):"]
     for audio_id, count in self.dataset.top_phrases.most_common(5):
         lines.append(
             "*[%2d]*  _%s_ (%d reproductions)" %
             (audio_id, self.dataset.get_audio_data(audio_id)['title'],
              count))
     self.reply_to(msg, "\n".join(lines), parse_mode="Markdown")
Example #8
0
 def send_random_phrase(self, msg):
     logger.info("%s: sending random phrase to user %s" % (msg.text, user_log_string(msg)))
     audio, duration = self.dataset.random_phrase()
     self.send_audio(msg.chat.id, audio, duration)
Example #9
0
 def audio_list(self, msg):
     logger.info("%s: sending phrase list to user %s" % (msg.text, user_log_string(msg)))
     text = ["Phrase list (use '/say ID' to choose phrase):"]
     for i, title in self.dataset.list_files():
         text.append("*[%2d]*  _%s_" % (i, title))
     self.reply_to(msg, "\n".join(text), parse_mode="Markdown")
Example #10
0
 def send_random_phrase(self, msg):
     logger.info("%s: sending random phrase to user %s" %
                 (msg.text, user_log_string(msg)))
     audio, duration = self.dataset.random_phrase()
     self.send_audio(msg.chat.id, audio, duration)