-
Notifications
You must be signed in to change notification settings - Fork 0
/
main[for github].py
57 lines (43 loc) · 1.61 KB
/
main[for github].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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import telebot
from flask import Flask, request
TOKEN = '<type your telebot token here>'
bot = telebot.TeleBot(token=TOKEN)
server = Flask(__name__)
@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.reply_to(message, "Howdy, how are you doing? \n Answer with the following replies \n /parade_state \n /sarprogramme \n /126parade_state \n /flyingprogramme \n Thank you")
@bot.message_handler(commands=['hello'])
def send_welcome(message):
bot.send_message(message.chat.id, "hello")
@bot.message_handler(commands=['parade_state'])
def get_ps(message):
with open("sqnexcel.csv","rb") as misc:
f=misc.read()
bot.send_message(message.chat.id,f)
@bot.message_handler(commands=['sarprogramme'])
def get_sar(message):
with open("sarprogramme.csv","rb") as misc1:
g=misc1.read()
bot.send_message(message.chat.id,g)
@bot.message_handler(commands=['126parade_state'])
def get_ps(message):
with open("126sqnexcel.csv","rb") as misc2:
h=misc2.read()
bot.send_message(message.chat.id,h)
@bot.message_handler(commands=['flyingprogramme'])
def get_ps(message):
with open("flyingprogramme.csv","rb") as misc3:
j=misc3.read()
bot.send_message(message.chat.id,j)
@server.route('/' + TOKEN, methods=['POST'])
def getMessage():
bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
return "!", 200
@server.route("/")
def webhook():
bot.remove_webhook()
bot.set_webhook(url='<type your Heroku web URL here>' + TOKEN)
return "!", 200
if __name__ == "__main__":
server.run(host="0.0.0.0", port=int(os.environ.get('PORT', 5000)))