def history(self, stanza, *args): """<from> <index> <size> 显示聊天历史""" email = get_email(stanza.get_from()) if args: return self._send_cmd_result(stanza, get_history(email, *args)) else: return self._send_cmd_result(stanza, get_history(email))
def command_help(m): rows = db.get_history(m.chat.id) temp = open("history.txt", 'w+') for row in rows: temp.write(f"{row[0]}[{row[1]}]: {row[2]}\n") temp = open('temp.txt', 'rb') bot.send_document(m.chat.id, temp)
def command_history(m): bot.send_chat_action(m.chat.id, 'typing') stri = "History: (last 10 messages)\n" rows = db.get_history(m.chat.id) rows.reverse() count = 0 for row in rows: if count >= 10: break stri += f'{row[0]}[{row[1]}]: {row[2]}\n' count += 1 bot.send_message(m.chat.id, stri)
def load_history_list(self): print('load_history_list 1') data = db.get_history() # cleaning list of history self.layout.clear_widgets() print('load_history_list 2') if len(data): print(len(data)) for el in data: print('->', el) btn = WrappedButton( text= f'{el["title"]} {"(completed)" if el["repetitions"] == 6 else ""}', size_hint_y=None, background_color=COLORS[str(el['repetitions'])], font_size=20, font_name='Arial', on_press=partial(sound.pronounce, el['title'])) print(COLORS[str(el['repetitions'])]) btn.bind(on_release=partial(self.open_dropdown, el['title'])) self.layout.add_widget(btn) self.layout.add_widget( MDIconButton(icon='delete', on_press=partial(self.delete_from_history, el['title']), size_hint=(0.25, None))) else: self.layout.add_widget( Label(text='No results', color=[62 / 255.0, 204 / 255.0, 237 / 255.0, 1.0]))
def small_random_sentence(m): bot.send_chat_action(m.chat.id, 'typing') time.sleep(1) bot.send_message(m.chat.id, generate(db.get_history(m.chat.id), SMALL))
def medium_random_sentence(m): bot.send_chat_action(m.chat.id, 'typing') time.sleep(1) bot.send_message(m.chat.id, generate(db.get_history(m.chat.id), MEDIUM))
def large_random_sentence(m): bot.send_chat_action(m.chat.id, 'typing') time.sleep(1) bot.send_message(m.chat.id, generate(db.get_history(m.chat.id), LARGE))
def random_sentence(m): bot.send_chat_action(m.chat.id, 'typing') time.sleep(1) bot.send_message( m.chat.id, generate(db.get_history(m.chat.id), random.randint(SMALL, LARGE)))
def random_sentence(m): text = generate(db.get_history(m.chat.id), LARGE) tts = gTTS(text, lang='ru') tts.save('audio_files/random_large.ogg') audio = open('audio_files/random_large.ogg', 'rb') bot.send_voice(m.chat.id, audio)
def GET(self, name): web.header('Content-Type', 'application/json; charset=utf-8', unique=True) all_houses = db.get_history(name) return json.dumps(all_houses, indent=4)
def get_history(): history = db.get_history(version_collection) response = data_to_response(history) response.status_code = 200 return response