imaginaryfriend/src/service/message_sender.py

57 lines
1.8 KiB
Python
Raw Normal View History

2016-11-12 23:55:48 +01:00
import logging
class MessageSender:
def __init__(self, bot):
self.bot = bot
def answer(self, entity, message):
2016-11-13 13:50:56 +01:00
if message == '':
return
2016-11-12 23:55:48 +01:00
logging.debug("[Chat %s %s answer] %s" %
(entity.chat.chat_type,
entity.chat.telegram_id,
message))
2016-11-14 18:42:51 +01:00
self.bot.send_message(chat_id=entity.chat.telegram_id, text=message)
2016-11-12 23:55:48 +01:00
def reply(self, entity, message):
2016-11-13 13:50:56 +01:00
if message == '':
return
2016-11-12 23:55:48 +01:00
logging.debug("[Chat %s %s reply] %s" %
(entity.chat.chat_type,
entity.chat.telegram_id,
message))
2016-11-14 18:42:51 +01:00
self.bot.send_message(chat_id=entity.chat.telegram_id,
reply_to_message_id=entity.message.message_id,
text=message)
2016-11-16 20:42:00 +01:00
def send_reply_markup(self, entity, message, reply_markup):
self.bot.send_message(chat_id=entity.chat.telegram_id,
text=message,
reply_markup=reply_markup)
2016-11-14 18:42:51 +01:00
def send_action(self, entity, action):
logging.debug("[Chat %s %s send_action] %s" %
(entity.chat.chat_type,
entity.chat.telegram_id,
action))
self.bot.send_chat_action(chat_id=entity.chat.telegram_id, action=action)
2016-11-12 23:55:48 +01:00
def send_sticker(self, entity, sticker_id):
2016-11-13 13:50:56 +01:00
if sticker_id == '':
return
logging.debug("[Chat %s %s send_sticker] %s" %
(entity.chat.chat_type,
entity.chat.telegram_id,
sticker_id))
2016-11-12 23:55:48 +01:00
2016-11-14 18:42:51 +01:00
self.bot.send_sticker(chat_id=entity.chat.telegram_id,
reply_to_message_id=entity.message.message_id,
sticker=sticker_id)