implement bots

This commit is contained in:
2019-11-12 20:13:56 +03:00
parent bf76e3c3ed
commit 58806f2103
47 changed files with 10251 additions and 305 deletions

18
bots/modules/echo.py Normal file
View 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