-
Notifications
You must be signed in to change notification settings - Fork 0
/
listen.py
29 lines (24 loc) · 838 Bytes
/
listen.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
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import json
with open('data.json') as json_file: #Load Token
data = json.load(json_file)
TOKEN = data["api_key"]
def on(update, context):
update.message.reply_text('AI has been enabled')
data["on"] = "1"
with open('data.json', 'w') as outfile:
json.dump(data, outfile)
def off(update, context):
update.message.reply_text('AI has been disabled')
data["on"] = "0"
with open('data.json', 'w') as outfile:
json.dump(data, outfile)
def main():
updater = Updater(TOKEN, use_context=True)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("on", on))
dispatcher.add_handler(CommandHandler("off", off))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()