implement bots
This commit is contained in:
18
bots/modules/echo.py
Normal file
18
bots/modules/echo.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
Reference in New Issue
Block a user