fix
This commit is contained in:
parent
c51d151bdc
commit
120b23a885
35
bot.py
35
bot.py
@ -63,26 +63,39 @@ class Core(TasksHandlerMixin):
|
|||||||
def handle_state_search(self):
|
def handle_state_search(self):
|
||||||
self.send_message('🤖 Поиски собеседника продолжаются')
|
self.send_message('🤖 Поиски собеседника продолжаются')
|
||||||
|
|
||||||
def send_message(self, text, chat_id=None, reply_markup=None, remove_keyboard=True, method='send_message', **kwargs):
|
def send_message(self, text, chat_id=None, reply_markup=None, remove_keyboard=True):
|
||||||
if text is None and not kwargs:
|
if text is None:
|
||||||
return
|
return
|
||||||
if reply_markup is None and remove_keyboard:
|
if reply_markup is None and remove_keyboard:
|
||||||
reply_markup = ReplyKeyboardRemove()
|
reply_markup = ReplyKeyboardRemove()
|
||||||
body = {
|
body = {
|
||||||
'chat_id': chat_id or self.chat_id,
|
'chat_id': chat_id or self.chat_id,
|
||||||
|
'text': text,
|
||||||
}
|
}
|
||||||
if text:
|
|
||||||
body['text'] = text
|
|
||||||
if reply_markup:
|
if reply_markup:
|
||||||
body['reply_markup'] = reply_markup.to_json()
|
body['reply_markup'] = reply_markup.to_json()
|
||||||
body.update(kwargs)
|
set_task(
|
||||||
|
'botalka_mailbox',
|
||||||
|
{
|
||||||
|
'project': 'roulette-bot',
|
||||||
|
'name': 'telegram-bot',
|
||||||
|
'method': 'send_message',
|
||||||
|
'body': body,
|
||||||
|
},
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
|
||||||
|
def send(self, chat_id, method, **kwargs):
|
||||||
set_task(
|
set_task(
|
||||||
'botalka_mailbox',
|
'botalka_mailbox',
|
||||||
{
|
{
|
||||||
'project': 'roulette-bot',
|
'project': 'roulette-bot',
|
||||||
'name': 'telegram-bot',
|
'name': 'telegram-bot',
|
||||||
'method': method,
|
'method': method,
|
||||||
'body': body,
|
'body': {
|
||||||
|
'chat_id': chat_id,
|
||||||
|
**kwargs,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
@ -100,15 +113,15 @@ class Core(TasksHandlerMixin):
|
|||||||
current_dialog = mongo.get_current_dialog(self.chat_id)
|
current_dialog = mongo.get_current_dialog(self.chat_id)
|
||||||
chat_to_send = current_dialog['chat_id_2'] if current_dialog['chat_id_1'] == self.chat_id else current_dialog['chat_id_1']
|
chat_to_send = current_dialog['chat_id_2'] if current_dialog['chat_id_1'] == self.chat_id else current_dialog['chat_id_1']
|
||||||
if self.message.photo:
|
if self.message.photo:
|
||||||
self.send_message(None, chat_to_send, method='send_photo', photo=self.message.photo[-1].file_id)
|
self.send(chat_to_send, 'send_photo', photo=self.message.photo[-1].file_id)
|
||||||
if self.message.sticker:
|
if self.message.sticker:
|
||||||
self.send_message(None, chat_to_send, method='send_data', data=self.message.sticker.file_id, data_type='sticker')
|
self.send(chat_to_send, 'send_data', data=self.message.sticker.file_id, data_type='sticker')
|
||||||
if self.message.voice:
|
if self.message.voice:
|
||||||
self.send_message(None, chat_to_send, method='send_voice', voice=self.message.voice.file_id)
|
self.send(chat_to_send, 'send_voice', voice=self.message.voice.file_id)
|
||||||
if self.message.video_note:
|
if self.message.video_note:
|
||||||
self.send_message(None, chat_to_send, method='send_video_note', data=self.message.video_note.file_id)
|
self.send(chat_to_send, 'send_video_note', data=self.message.video_note.file_id)
|
||||||
if self.message.animation:
|
if self.message.animation:
|
||||||
self.send_message(None, chat_to_send, method='send_animation', animation=self.message.animation.file_id)
|
self.send(chat_to_send, 'send_animation', animation=self.message.animation.file_id)
|
||||||
self.send_message(self.message_text, chat_to_send)
|
self.send_message(self.message_text, chat_to_send)
|
||||||
|
|
||||||
def start_new_dialog(self, chat_ids):
|
def start_new_dialog(self, chat_ids):
|
||||||
|
Loading…
Reference in New Issue
Block a user