1
0
mirror of https://github.com/MarkParker5/STARK.git synced 2025-02-17 11:55:35 +02:00

remove index.html from qa

fix telegram bot voice messages
This commit is contained in:
MarkParker5 2021-12-07 02:41:52 +02:00
parent 835cc16574
commit dd84405067
2 changed files with 6 additions and 4 deletions

View File

@ -43,8 +43,12 @@ class TelegramBot(Control, CommandsContextManagerDelegate):
if response.text:
self.bot.send_message(id, response.text)
if response.voice:
if bytes := self.voice.generate(response.voice).getBytes():
self.bot.send_voice(id, bytes)
path = self.voice.generate(response.voice).path
voiceFile = open(path, 'rb')
try:
self.bot.send_voice(id, voiceFile)
finally:
voiceFile.close()
# Telebot

View File

@ -52,8 +52,6 @@ class QAHelper():
def googleSearch(word):
responce = requests.get(f'https://www.google.ru/search?&q={word}&lr=lang_ru&lang=ru',
headers = {'User-Agent': 'Mozilla/5.0'})
with open('index.html', 'wb') as f:
f.write(responce.content)
page = BS(responce.content, 'html.parser')
info = page.select('div.BNeawe>div>div.BNeawe')
return info[0].get_text() if info else ''