-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatBotModel.py
33 lines (27 loc) · 997 Bytes
/
ChatBotModel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import telegram
from telegram.ext import Updater, CommandHandler
class TelegramBot:
def __init__(self, name, token):
self.core = telegram.Bot(token)
self.updater = Updater(token)
self.id = 937210580
self.name = name
def sendMessage(self, text):
self.core.sendMessage(chat_id = self.id, text=text)
def stop(self):
self.updater.start_polling()
self.updater.dispatcher.stop()
self.updater.job_queue.stop()
self.updater.stop()
mytoken='972430101:AAEBh2y65N2fDDCoqmXB-8UWrsh9V5rmWLc'
class my3736(TelegramBot):
def __init__(self):
self.token = mytoken
TelegramBot.__init__(self, 'my3736', self.token)
self.updater.stop()
def add_handler(self, cmd, func):
self.updater.dispatcher.add_handler(CommandHandler(cmd, func))
def start(self):
self.sendMessage('my3736 봇이 잠에서 깨어납니다.')
self.updater.start_polling()
self.updater.idle()