(self,token,callback)
| 8 | |
| 9 | class TelegramBot: |
| 10 | def __init__(self,token,callback): |
| 11 | self.token = token |
| 12 | self.callback = callback |
| 13 | self.rbuf = bytearray(4096) |
| 14 | self.rbuf_mv = memoryview(self.rbuf) |
| 15 | self.rbuf_used = 0 |
| 16 | self.active = True # So we can stop the task with .stop() |
| 17 | self.debug = False |
| 18 | self.missed_write = None # Failed write payload. This is useful |
| 19 | # in order to retransfer after reconnection. |
| 20 | |
| 21 | # Array of outgoing messages. Each entry is a hash with |
| 22 | # chat_id and text fields. |
| 23 | self.outgoing = [] |
| 24 | self.pending = False # Pending HTTP request, waiting for reply. |
| 25 | self.reconnect = True # We need to reconnect the socket, either for |
| 26 | # the first time or after errors. |
| 27 | self.offset = 0 # Next message ID offset. |
| 28 | self.watchdog_timeout_ms = 60000 # 60 seconds max idle time. |
| 29 | |
| 30 | # Stop the task handling the bot. This should be called before |
| 31 | # destroying the object, in order to also terminate the task. |
nothing calls this directly
no outgoing calls
no test coverage detected