Quantcast
Viewing all articles
Browse latest Browse all 5391

Troubleshooting • Re: Need help with Telepot

Hi. Please be indulgent since i'm a beginner.
I am trying to delete the outgoing message sent by myself to telegram without success.
Here is the part of my script :

Code:

import timeimport oscurrentTime = time.time()tomorrow = currentTime + 43320import telepotfrom picamera import PiCameraimport RPi.GPIO as GPIOfrom time import sleepimport datetimefrom telepot.loop import MessageLoopfrom subprocess import call PIR    = 4camera = PiCamera()camera.resolution = (640, 480)camera.framerate = 25GPIO.setwarnings(False)  GPIO.setmode(GPIO.BCM)GPIO.setup(PIR, GPIO.IN)motion = 0motionNew = 0 def handle(msg):    global telegramText    global chat_id    global message_idchat_id = msg['chat']['id']    telegramText = msg['text']    message_id = msg['message_id']    MessageId = message_id      print('Message received from ' + str(chat_id))              if telegramText == '/start':                print(MessageId) # Here I'm getting my message Id without problem        time.sleep(5)                bot.sendMessage(chat_id, 'Security camera is activated.')                bot.deleteMessage(chat_id,MessageId,) # Here occurs  My Problem                print('The message has been deleted')        time.sleep(10)
When executing the script everything is going ok BUT i'm getting this message related to the message deletion :
TypeError: deleteMessage() takes 2 positional arguments but 3 were given .
What i'm doing wrong. Thanks for any help




Inspecting the line you identify as troublesome -

Code:

bot.deleteMessage(chat_id,MessageId,) # Here occurs  My Problem

Just a crazy, untested idea, but could it be that dangling comma [ , ] is confusing Python into thinking there is going to be another argument? Which it doesn't expect.



{Disclaimer: I have no knowledge of what telepot is or does... }



You might also have a syntax or formatting problem in the definition of your handle() function.

Statistics: Posted by B.Goode — Tue Feb 06, 2024 6:18 pm



Viewing all articles
Browse latest Browse all 5391

Trending Articles