19 lines
621 B
Python
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
|