telepot
telepot copied to clipboard
Telepot stopped after some time
Hi! I've stuck with with issue, when telepot stopped receiving any updates after some time. Script is running on my Raspberry Pi 3 model B. :
Raspbian GNU/Linux 9 (stretch)
Linux TopoR-Pi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux
Scripts running by sh in rc.local:
setsid sh /home/pi/Documents/Scripts/launcher.sh &
And launcher.sh:
sudo pkill -f chkDir.py
sudo pkill -f tgmMain.py
sudo pkill -f chkDisc.py
cd /
cd home/pi/Documents/Scripts
setsid python -u chkDir.py >> chkDirStd.log &
setsid python -u tgmMain.py >> tgmStd.log &
setsid python chkDisc.py &
cd /
Almost entirely example script:
import time
import random
import datetime
import telepot
import os
import logging
from telepot.loop import MessageLoop
bot = telepot.Bot('XXX:YYY')
def handle(msg):
chat_id = msg['chat']['id']
command = msg['text']
logging.info('Recieved command: %s' % command)
if command == '/roll':
bot.sendMessage(chat_id, random.randint(1,6))
logging.info('Sended Roll')
elif command == '/time':
bot.sendMessage(chat_id, str(datetime.datetime.now()))
logging.info('Sended time')
elif command == '/test':
os.system('xclock &')
def sendMsg(text):
bot.sendMessage('ZZZ', text)
logging.info('Sended text: %s' % text)
logging.basicConfig(filename='tgmMain.log',format='%(asctime)s %(message)s',level=logging.DEBUG)
MessageLoop(bot, handle).run_as_thread()
logging.info('Telegram bot started!')
print('Telegram stdout log started.')
while 1:
time.sleep(30)
Entire tgmStd.log:
Telegram stdout log started.
tgmMain.log (last update 9 hrs ago, script still running by system):
2018-02-09 13:14:09,894 Telegram bot started!
2018-02-09 13:14:09,900 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=0, status=None)
2018-02-09 13:14:09,902 Starting new HTTPS connection (1): api.telegram.org
2018-02-09 13:14:30,287 https://api.telegram.org:443 "POST /botXXX:YYY/getUpdates HTTP/1.1" 200 23
2018-02-09 13:14:30,393 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=0, status=None)
2018-02-09 13:14:37,487 https://api.telegram.org:443 "POST /botXXX:YYY/getUpdates HTTP/1.1" 200 553
2018-02-09 13:14:37,490 Recieved command: /time
2018-02-09 13:14:37,494 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=0, status=None)
2018-02-09 13:14:37,593 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=0, status=None)
2018-02-09 13:14:37,594 Starting new HTTPS connection (2): api.telegram.org
2018-02-09 13:14:37,598 https://api.telegram.org:443 "POST /botXXX:YYY/sendMessage HTTP/1.1" 200 357
2018-02-09 13:14:37,601 Sended time
...
2018-02-12 03:11:12,660 https://api.telegram.org:443 "POST /botXXX:YYY/getUpdates HTTP/1.1" 200 23
2018-02-12 03:11:12,765 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=0, status=None)
2018-02-12 03:11:32,988 https://api.telegram.org:443 "POST /botXXX:YYY/getUpdates HTTP/1.1" 200 23
2018-02-12 03:11:33,094 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=0, status=None)
2018-02-12 03:11:53,599 https://api.telegram.org:443 "POST /botXXX:YYY/getUpdates HTTP/1.1" 200 23
2018-02-12 03:11:53,704 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=0, status=None)
Other scripts sending messages to the bot via telepot, but loop in the hadler just stopping at random times.
Reminiscent of #239 and #242. I am sorry I still haven't fixed those issues. Someone suggested some solutions there which may be helpful.
I have same problem. None of the workarounds has helped