-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathepush_bot.py
35 lines (29 loc) · 836 Bytes
/
epush_bot.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
34
35
import telebot
import os
from config import *
from flask import Flask, request
server = Flask(__name__)
import importdir
importdir.do("features", globals())
@server.route('/'+ TOKEN, methods=['POST'])
def getMessage():
request_object = request.stream.read().decode("utf-8")
update_to_json = [telebot.types.Update.de_json(request_object)]
bot.process_new_updates(update_to_json)
return "got Message bro"
@server.route('/hook')
def webhook():
url=URL
bot.remove_webhook()
bot.set_webhook(url + TOKEN)
return f"Webhook set to {url}"
@server.route('/')
def thanks():
url=URL
return f"Thanks you've reach chukwudi bot {url}"
if DEBUG==True:
bot.remove_webhook()
bot.polling()
else:
if __name__ == "__main__":
server.run(host="0.0.0.0", port=int(os.environ.get('PORT', 5000)))