MCPcopy Create free account
hub / github.com/antirez/freakwan / __init__

Method __init__

telegram.py:10–28  ·  view source on GitHub ↗
(self,token,callback)

Source from the content-addressed store, hash-verified

8
9class 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.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected