12
12
13
13
import subprocess
14
14
15
- from telegram import (Bot , TelegramError , broadcaster , Broadcaster ,
15
+ from telegram import (Bot , TelegramError , broadcaster , Dispatcher ,
16
16
NullHandler )
17
17
from telegram .utils .webhookhandler import (WebhookServer , WebhookHandler )
18
18
@@ -49,8 +49,8 @@ def __init__(self, token, base_url=None, workers=4):
49
49
50
50
self .bot = Bot (token , base_url )
51
51
self .update_queue = Queue ()
52
- self .broadcaster = Broadcaster (self .bot , self .update_queue ,
53
- workers = workers )
52
+ self .dispatcher = Dispatcher (self .bot , self .update_queue ,
53
+ workers = workers )
54
54
self .last_update_id = 0
55
55
self .logger = logging .getLogger (__name__ )
56
56
self .running = False
@@ -71,8 +71,8 @@ def start_polling(self, poll_interval=1.0, timeout=10, network_delay=2):
71
71
"""
72
72
73
73
# Create Thread objects
74
- broadcaster_thread = Thread (target = self .broadcaster .start ,
75
- name = "broadcaster " )
74
+ dispatcher_thread = Thread (target = self .dispatcher .start ,
75
+ name = "dispatcher " )
76
76
event_handler_thread = Thread (target = self ._start_polling ,
77
77
name = "eventhandler" ,
78
78
args = (poll_interval , timeout ,
@@ -81,7 +81,7 @@ def start_polling(self, poll_interval=1.0, timeout=10, network_delay=2):
81
81
self .running = True
82
82
83
83
# Start threads
84
- broadcaster_thread .start ()
84
+ dispatcher_thread .start ()
85
85
event_handler_thread .start ()
86
86
87
87
# Return the update queue so the main thread can insert updates
@@ -103,16 +103,16 @@ def start_webhook(self, host, port, cert, key, listen='0.0.0.0'):
103
103
"""
104
104
105
105
# Create Thread objects
106
- broadcaster_thread = Thread (target = self .broadcaster .start ,
107
- name = "broadcaster " )
106
+ dispatcher_thread = Thread (target = self .dispatcher .start ,
107
+ name = "dispatcher " )
108
108
event_handler_thread = Thread (target = self ._start_webhook ,
109
109
name = "eventhandler" ,
110
110
args = (host , port , cert , key , listen ))
111
111
112
112
self .running = True
113
113
114
114
# Start threads
115
- broadcaster_thread .start ()
115
+ dispatcher_thread .start ()
116
116
event_handler_thread .start ()
117
117
118
118
# Return the update queue so the main thread can insert updates
@@ -122,7 +122,7 @@ def _start_polling(self, poll_interval, timeout, network_delay):
122
122
"""
123
123
Thread target of thread 'eventhandler'. Runs in background, pulls
124
124
updates from Telegram and inserts them in the update queue of the
125
- Broadcaster .
125
+ Dispatcher .
126
126
"""
127
127
128
128
current_interval = poll_interval
@@ -149,7 +149,7 @@ def _start_polling(self, poll_interval, timeout, network_delay):
149
149
150
150
sleep (current_interval )
151
151
except TelegramError as te :
152
- # Put the error into the update queue and let the Broadcaster
152
+ # Put the error into the update queue and let the Dispatcher
153
153
# broadcast it
154
154
self .update_queue .put (te )
155
155
sleep (current_interval )
@@ -200,9 +200,9 @@ def _start_webhook(self, host, port, cert, key, listen):
200
200
201
201
def stop (self ):
202
202
"""
203
- Stops the polling thread and the broadcaster
203
+ Stops the polling thread and the dispatcher
204
204
"""
205
- self .logger .info ('Stopping Event Handler and Broadcaster ...' )
205
+ self .logger .info ('Stopping Event Handler and Dispatcher ...' )
206
206
self .running = False
207
207
208
208
if self .httpd :
@@ -212,9 +212,9 @@ def stop(self):
212
212
self .httpd .shutdown ()
213
213
self .httpd = None
214
214
215
- self .logger .debug ("Requesting Broadcaster to stop..." )
216
- self .broadcaster .stop ()
215
+ self .logger .debug ("Requesting Dispatcher to stop..." )
216
+ self .dispatcher .stop ()
217
217
while broadcaster .running_async > 0 :
218
218
sleep (1 )
219
219
220
- self .logger .debug ("Broadcaster stopped." )
220
+ self .logger .debug ("Dispatcher stopped." )
0 commit comments