MaxGit32 commited on
Commit
d8c18ec
1 Parent(s): a353273

Upload telegram.py

Browse files
Files changed (1) hide show
  1. pages/telegram.py +119 -0
pages/telegram.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import telebot
2
+ from telebot import types
3
+ import asyncio
4
+
5
+ from telebot.async_telebot import AsyncTeleBot
6
+
7
+ # from Warning import *
8
+
9
+
10
+ #### Julian neu #####
11
+
12
+ with open("token.txt") as file:
13
+ token = file.read()
14
+ bot = AsyncTeleBot(token)
15
+
16
+ @bot.message_handler(commands=['start'])
17
+ async def handle_start(message):
18
+ #print(message)
19
+ button_akt_Meldung = types.InlineKeyboardButton('Aktuelle Meldungen zum Wetter', callback_data='akt_Meldung')
20
+ button_allg = types.InlineKeyboardButton('Allgemeine Informationen zum Katastrophenschutz', callback_data='allg')
21
+
22
+ keyboard = types.InlineKeyboardMarkup()
23
+ keyboard.add(button_allg)
24
+
25
+ await bot.reply_to(message, text='Keyboard example', reply_markup=keyboard)
26
+
27
+ @bot.callback_query_handler(func=lambda call: True)
28
+ async def handle_button_click(call):
29
+ match call.data:
30
+ case "allg":
31
+ # Hier wird die Funktion aufgerufen, die du mit Button 1 verknüpfen möchtest
32
+ await function_allg(call.message)
33
+ case "akt_Meldung":
34
+ # Hier wird die Funktion aufgerufen, die du mit Button 1 verknüpfen möchtest
35
+ await function_akt_meldungen(call.message)
36
+
37
+ case _:
38
+ # Hier wird die Funktion aufgerufen, die du mit Button 2 verknüpfen möchtest
39
+ await bot.send_message(call.message.chat.id, "Der Button ist nicht angebunden.")
40
+
41
+
42
+ async def function_allg(message):
43
+ # hier bitte den Zaubereipart einsenden
44
+ antwort = "Du möchtest allgemeine Informationen"
45
+ await bot.send_message(message, antwort)
46
+
47
+ async def function_akt_meldungen(message):
48
+ # hier bitte Pauls abfrage einfügen
49
+ antwort = "Du möchtest Wetter Informationen"
50
+ await bot.send_message(message, antwort)
51
+
52
+ # Handle '/start' and '/help'
53
+ # @bot.message_handler(commands=['help', 'start'])
54
+ # async def send_welcome(message):
55
+ # await bot.reply_to(message, """hhjvkhv\
56
+ # Hi there, I am EchoBot.
57
+ # I am here to echo your kind words back to you. Just say anything nice and I'll say the exact same thing to you!\
58
+ # """)
59
+
60
+ @bot.message_handler(func=lambda message: True)
61
+ async def get_Message(message):
62
+ frage = message.text
63
+
64
+ await bot.reply_to(message, frage)
65
+
66
+
67
+
68
+
69
+ asyncio.run(bot.polling())
70
+
71
+
72
+
73
+
74
+
75
+
76
+ # ### Paul alt ####
77
+ # with open("token.txt") as file:
78
+ # token = file.read()
79
+
80
+ # bot = telebot.TeleBot(token)
81
+ # frage = ""
82
+
83
+ # # Startnachricht
84
+ # startnachricht = "Disclaimer zu unserem Chatbot: ..."
85
+ # markup = types.InlineKeyboardMarkup()
86
+ # button = types.InlineKeyboardButton('Aktuelle Informationen zu Warnungen', callback_data='api_warnung')
87
+ # button = types.InlineKeyboardButton('Allgemeine Informationen zu Katastrophen', callback_data='allg_infos')
88
+ # markup.add(button)
89
+
90
+ # bot.send_message(chat_id='6475480143',text=startnachricht, reply_markup=markup)
91
+
92
+ # # Command Handler
93
+ # @bot.message_handler(commands=['start'])
94
+ # def start(message):
95
+ # markup = types.InlineKeyboardMarkup()
96
+ # button = types.InlineKeyboardButton('Aktuelle Informationen zu Warnungen', callback_data='api_warnung')
97
+
98
+ # markup.add(button)
99
+
100
+ # bot.send_message(message.chat.id, 'Hallo! Klicke auf den Button:', reply_markup=markup)
101
+
102
+ # # Nachricht erkennen
103
+ # @bot.callback_query_handler(func=lambda call: True)
104
+ # def callback_handler(call):
105
+ # # Antworten wenn API Infos gefordert
106
+ # if call.data == 'api_warnung':
107
+ # bot.send_message(call.message.chat.id, 'Antworten zu aktuellen Informationen:')
108
+ # if call.data == 'allg_infos':
109
+ # bot.send_message(call.message.chat.id, 'Antworten zu allgemeinen Informationen:')
110
+
111
+ # # Get_Message
112
+ # @bot.message_handler(func=lambda message: True)
113
+ # def get_Message(message):
114
+ # #bot.reply_to(message, message.text)
115
+ # frage = message.text
116
+ # print(frage)
117
+
118
+ # # Bot starten
119
+ # bot.infinity_polling()