diff --git a/docs/Glucosemeter Project Logboek.docx b/docs/Glucosemeter Project Logboek.docx index e0261db..8106bf3 100644 Binary files a/docs/Glucosemeter Project Logboek.docx and b/docs/Glucosemeter Project Logboek.docx differ diff --git a/src/TeleBot.py b/src/TeleBot.py index 99f77e3..c640e03 100644 --- a/src/TeleBot.py +++ b/src/TeleBot.py @@ -34,8 +34,13 @@ async def subscribe(update: Update, context: ContextTypes.DEFAULT_TYPE): # await context.bot.send_message(chat_id=update.effective_chat.id, text=update.message.chat.id) #Mqtt.publish(send_topic,1) -async def gluc_command(update: Update, context: CallbackContext): - args = ' '.join(context.args) +async def gluc_eat(update: Update, context: CallbackContext): #Runs on /ge command + args = "e " + ' '.join(context.args) #Joins message into string split by spaces and adds e to the front + current_user = User[str(update.effective_chat.id)].name #Checks wich user sends the message + Mqtt.publish(send_topic_glucose + current_user.lower(), args) #Sends message with current_user added to the end of topic + +async def gluc_comp(update: Update, context: CallbackContext): #Runs on /gc command + args = "c " + ' '.join(context.args) #Joins message into string split by spaces and adds c to the front current_user = User[str(update.effective_chat.id)].name #Checks wich user sends the message Mqtt.publish(send_topic_glucose + current_user.lower(), args) #Sends message with current_user added to the end of topic @@ -87,13 +92,15 @@ Mqtt.loop_start() #Start Mqtt def main():#This is the main loop application = ApplicationBuilder().token(BotToken).build() - gluc_handler = CommandHandler('g', gluc_command) + eat_handler = CommandHandler('ge', gluc_eat) + comp_handler = CommandHandler('gc', gluc_comp) subscribe_handler = CommandHandler('subscribe', subscribe) server_handler = CommandHandler('s', server_command) job_queue = application.job_queue job_minute = job_queue.run_repeating(Cat , interval=1, first=1) #job_offline = job_queue.run_repeating(callback_offline , interval=interval_offline_message) - application.add_handler(gluc_handler) + application.add_handler(eat_handler) + application.add_handler(comp_handler) application.add_handler(subscribe_handler) application.add_handler(server_handler) application.run_polling()