File size: 3,825 Bytes
d8c18ec
 
 
58cd5c0
d8c18ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58cd5c0
d8c18ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# import telebot
from telebot import types
import asyncio
from bot import get_llm_answer

from telebot.async_telebot import AsyncTeleBot

# from Warning import *


#### Julian neu #####

with open("token.txt") as file:
    token = file.read()
bot = AsyncTeleBot(token)

@bot.message_handler(commands=['start'])
async def handle_start(message):
    #print(message)
    button_akt_Meldung = types.InlineKeyboardButton('Aktuelle Meldungen zum Wetter', callback_data='akt_Meldung')
    button_allg = types.InlineKeyboardButton('Allgemeine Informationen zum Katastrophenschutz', callback_data='allg')

    keyboard = types.InlineKeyboardMarkup()
    keyboard.add(button_allg)

    await bot.reply_to(message, text='Keyboard example', reply_markup=keyboard)

@bot.callback_query_handler(func=lambda call: True)
async def handle_button_click(call):
    match call.data:
        case "allg":
            # Hier wird die Funktion aufgerufen, die du mit Button 1 verknüpfen möchtest
            await function_allg(call.message)
        case "akt_Meldung":
            # Hier wird die Funktion aufgerufen, die du mit Button 1 verknüpfen möchtest
            await function_akt_meldungen(call.message)

        case _:
            # Hier wird die Funktion aufgerufen, die du mit Button 2 verknüpfen möchtest
            await bot.send_message(call.message.chat.id, "Der Button ist nicht angebunden.")


async def function_allg(message):
    # hier bitte den Zaubereipart einsenden
    antwort = get_llm_answer(message.text)
    await bot.send_message(message, antwort)

async def function_akt_meldungen(message):
    # hier bitte Pauls abfrage einfügen
    antwort = "Du möchtest Wetter Informationen"
    await bot.send_message(message, antwort)

# Handle '/start' and '/help'
# @bot.message_handler(commands=['help', 'start'])
# async def send_welcome(message):
#     await bot.reply_to(message, """hhjvkhv\
#             Hi there, I am EchoBot.
#             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!\
#             """)

@bot.message_handler(func=lambda message: True)
async def get_Message(message):
    frage = message.text
    
    await bot.reply_to(message, frage)




asyncio.run(bot.polling())






# ### Paul alt ####
# with open("token.txt") as file:
#     token = file.read()

# bot = telebot.TeleBot(token)
# frage = ""

# # Startnachricht 
# startnachricht = "Disclaimer zu unserem Chatbot: ..."
# markup = types.InlineKeyboardMarkup()
# button = types.InlineKeyboardButton('Aktuelle Informationen zu Warnungen', callback_data='api_warnung')
# button = types.InlineKeyboardButton('Allgemeine Informationen zu Katastrophen', callback_data='allg_infos')
# markup.add(button)

# bot.send_message(chat_id='6475480143',text=startnachricht, reply_markup=markup)

# # Command Handler
# @bot.message_handler(commands=['start'])
# def start(message):
#     markup = types.InlineKeyboardMarkup()
#     button = types.InlineKeyboardButton('Aktuelle Informationen zu Warnungen', callback_data='api_warnung')

#     markup.add(button)

#     bot.send_message(message.chat.id, 'Hallo! Klicke auf den Button:', reply_markup=markup)

# # Nachricht erkennen
# @bot.callback_query_handler(func=lambda call: True)
# def callback_handler(call):
#     # Antworten wenn API Infos gefordert
#     if call.data == 'api_warnung':
#         bot.send_message(call.message.chat.id, 'Antworten zu aktuellen Informationen:')
#     if call.data == 'allg_infos': 
#         bot.send_message(call.message.chat.id, 'Antworten zu allgemeinen Informationen:')

# # Get_Message
# @bot.message_handler(func=lambda message: True)
# def get_Message(message):
# 	#bot.reply_to(message, message.text)
# 	frage = message.text
# 	print(frage)

# # Bot starten 
# bot.infinity_polling()