nickoala / telepot

Python framework for Telegram Bot API
MIT License
2.42k stars 474 forks source link

Probelm after internet lost with receive messages #449

Closed FireRasPi closed 5 years ago

FireRasPi commented 5 years ago

Hi there! I have one big problem with my telepot. Every time when i lost the internet connection the receiving process went down.

I have just telepot on this Raspberry

Script:

import time
import telepot
import subprocess
import datetime
import sys

chat_id = 'XXXXXXXXXX'
def handle(msg):
    try:
        chat_id = msg['chat']['id']
        command = msg['text']
        bot.sendMessage(chat_id, (str(datetime.datetime.now())+ ": " +str(command) ))
    except:
        pass
try:
        bot = telepot.Bot('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
        bot.message_loop(handle)
        command="Start running"
        bot.sendMessage(chat_id, (str(datetime.datetime.now())+ ": " +str(command) ))
except:
        print "telegram down"

file1 = open("/home/pi/Desktop/TestRun.txt","w")
file1.write("1")
file1.close()

bedingung = "1"
while (bedingung == "1"):
    file = open("/home/pi/Desktop/TestRun.txt", "r")
    bedingung = file.read(1)
    file.close()

    time.sleep(5)
    command="runnig"
    try:
        bot.sendMessage(chat_id, (str(datetime.datetime.now())+ ": " +str(command) ))
    except:
        pass

try:
        command="End of Testsoftware"
        bot.sendMessage(chat_id, (str(datetime.datetime.now())+ ": " +str(command) ))
except:
        pass
FireRasPi commented 5 years ago

After build a complete new system it´s working... Problem is not the telepot