Added 2 separed commands for glucose
Ik heb het veranderd zodat je nu /gc of /ge kan doen.
This commit is contained in:
parent
aa248bff7c
commit
025105bf48
2 changed files with 11 additions and 4 deletions
Binary file not shown.
|
|
@ -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)
|
await context.bot.send_message(chat_id=update.effective_chat.id, text=update.message.chat.id)
|
||||||
#Mqtt.publish(send_topic,1)
|
#Mqtt.publish(send_topic,1)
|
||||||
|
|
||||||
async def gluc_command(update: Update, context: CallbackContext):
|
async def gluc_eat(update: Update, context: CallbackContext): #Runs on /ge command
|
||||||
args = ' '.join(context.args)
|
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
|
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
|
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
|
def main():#This is the main loop
|
||||||
application = ApplicationBuilder().token(BotToken).build()
|
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)
|
subscribe_handler = CommandHandler('subscribe', subscribe)
|
||||||
server_handler = CommandHandler('s', server_command)
|
server_handler = CommandHandler('s', server_command)
|
||||||
job_queue = application.job_queue
|
job_queue = application.job_queue
|
||||||
job_minute = job_queue.run_repeating(Cat , interval=1, first=1)
|
job_minute = job_queue.run_repeating(Cat , interval=1, first=1)
|
||||||
#job_offline = job_queue.run_repeating(callback_offline , interval=interval_offline_message)
|
#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(subscribe_handler)
|
||||||
application.add_handler(server_handler)
|
application.add_handler(server_handler)
|
||||||
application.run_polling()
|
application.run_polling()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue