Compare commits

..

8 Commits

Author SHA1 Message Date
6d305f7e98 Merge pull request 'master' (#11) from master into prod
Reviewed-on: #11
2024-11-30 15:16:16 +03:00
3a19bdfdd5 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 4s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
Deploy Prod / Build (pull_request) Successful in 4s
Deploy Prod / Push (pull_request) Successful in 9s
Deploy Prod / Deploy prod (pull_request) Successful in 6s
2024-11-30 15:10:40 +03:00
243b9e8c9c fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2024-11-30 15:08:09 +03:00
120b23a885 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 4s
Deploy Dev / Push (pull_request) Successful in 7s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
2024-11-30 15:05:43 +03:00
c51d151bdc fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2024-11-30 14:44:48 +03:00
a042a033a6 fix 2024-11-30 14:23:01 +03:00
c759cacf9c fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 6s
Deploy Dev / Push (pull_request) Successful in 7s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
2024-11-30 13:15:36 +03:00
30006955b5 Merge pull request 'fix' (#2) from master into prod
Reviewed-on: #2
2024-10-22 00:24:10 +03:00

35
bot.py
View File

@@ -63,24 +63,39 @@ class Core(TasksHandlerMixin):
def handle_state_search(self):
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 not text:
return
if reply_markup is None and remove_keyboard:
reply_markup = ReplyKeyboardRemove()
body = {
'chat_id': chat_id or self.chat_id,
'text': text,
}
if text:
body['text'] = text
if reply_markup:
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(
'botalka_mailbox',
{
'project': 'roulette-bot',
'name': 'telegram-bot',
'method': method,
'body': body,
'body': {
'chat_id': chat_id,
**kwargs,
},
},
1,
)
@@ -98,15 +113,15 @@ class Core(TasksHandlerMixin):
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']
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:
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:
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:
self.send_message(None, chat_to_send, method='send_data', data=self.message.video_note.file_id, data_type='video_note')
self.send(chat_to_send, 'send_video_note', data=self.message.video_note.file_id)
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', data=self.message.animation.file_id)
self.send_message(self.message_text, chat_to_send)
def start_new_dialog(self, chat_ids):