Support empty string

Als er geen tijd wordt gespecificeerd, dan krijg je voortaan geen error melding meer.
This commit is contained in:
gjkoolen 2025-03-10 20:28:46 +01:00
parent 025105bf48
commit 97e72fdd56
2 changed files with 3 additions and 2 deletions

View file

@ -126,6 +126,7 @@ def on_message(client, userdata, msg): #This runs everytime a mqtt message
global last_bolus_time global last_bolus_time
global last_bolus_type global last_bolus_type
args = msg.payload.decode() args = msg.payload.decode()
print(f"incoming /g command {args}")
args_list = args.split(" ") args_list = args.split(" ")
if not args: if not args:
#Empty string #Empty string

View file

@ -35,12 +35,12 @@ async def subscribe(update: Update, context: ContextTypes.DEFAULT_TYPE): #
#Mqtt.publish(send_topic,1) #Mqtt.publish(send_topic,1)
async def gluc_eat(update: Update, context: CallbackContext): #Runs on /ge command 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 args = "e" if not context.args else "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 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
async def gluc_comp(update: Update, context: CallbackContext): #Runs on /gc command 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 args = "c" if not context.args else "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