telegram_bots/bots/modules/echo.py
2019-11-12 20:13:56 +03:00

19 lines
621 B
Python

from django.db import models
from telegram import Update
from telegram.ext import Dispatcher, CallbackContext, MessageHandler, Filters
from bots.models import TelegramBotModuleConfig
class EchoBotModuleConfig(TelegramBotModuleConfig):
prefix = models.TextField()
MODULE_NAME = 'Echo'
def message_handler(self, update: Update, ctx: CallbackContext):
update.effective_message.reply_text(self.prefix + update.effective_message.text)
def build_dispatcher(self, dispatcher: Dispatcher):
dispatcher.add_handler(MessageHandler(Filters.text, self.message_handler))
return dispatcher