@@ -67,6 +67,8 @@ def __init__(self, token, threaded=True, skip_pending=False):
6767
6868 self .message_handlers = []
6969 self .edited_message_handlers = []
70+ self .channel_post_handlers = []
71+ self .edited_channel_post_handlers = []
7072 self .inline_handlers = []
7173 self .chosen_inline_handlers = []
7274 self .callback_query_handlers = []
@@ -129,6 +131,8 @@ def __retrieve_updates(self, timeout=20):
129131 def process_new_updates (self , updates ):
130132 new_messages = []
131133 edited_new_messages = []
134+ new_channel_posts = []
135+ new_edited_channel_posts = []
132136 new_inline_querys = []
133137 new_chosen_inline_results = []
134138 new_callback_querys = []
@@ -139,6 +143,10 @@ def process_new_updates(self, updates):
139143 new_messages .append (update .message )
140144 if update .edited_message :
141145 edited_new_messages .append (update .edited_message )
146+ if update .channel_post :
147+ new_channel_posts .append (update .channel_post )
148+ if update .edited_channel_post :
149+ new_edited_channel_posts .append (update .edited_channel_post )
142150 if update .inline_query :
143151 new_inline_querys .append (update .inline_query )
144152 if update .chosen_inline_result :
@@ -150,6 +158,10 @@ def process_new_updates(self, updates):
150158 self .process_new_messages (new_messages )
151159 if len (edited_new_messages ) > 0 :
152160 self .process_new_edited_messages (edited_new_messages )
161+ if len (new_channel_posts ) > 0 :
162+ self .process_new_channel_posts (new_channel_posts )
163+ if len (new_edited_channel_posts ) > 0 :
164+ self .process_new_edited_channel_posts (new_edited_channel_posts )
153165 if len (new_inline_querys ) > 0 :
154166 self .process_new_inline_query (new_inline_querys )
155167 if len (new_chosen_inline_results ) > 0 :
@@ -167,6 +179,12 @@ def process_new_messages(self, new_messages):
167179 def process_new_edited_messages (self , edited_message ):
168180 self ._notify_command_handlers (self .edited_message_handlers , edited_message )
169181
182+ def process_new_channel_posts (self , channel_post ):
183+ self ._notify_command_handlers (self .channel_post_handlers , channel_post )
184+
185+ def process_new_edited_channel_posts (self , edited_channel_post ):
186+ self ._notify_command_handlers (self .edited_channel_post_handlers , edited_channel_post )
187+
170188 def process_new_inline_query (self , new_inline_querys ):
171189 self ._notify_command_handlers (self .inline_handlers , new_inline_querys )
172190
@@ -748,6 +766,38 @@ def decorator(handler):
748766 def add_edited_message_handler (self , handler_dict ):
749767 self .edited_message_handlers .append (handler_dict )
750768
769+ def channel_post_handler (self , commands = None , regexp = None , func = None , content_types = ['text' ], ** kwargs ):
770+ def decorator (handler ):
771+ handler_dict = self ._build_handler_dict (handler ,
772+ commands = commands ,
773+ regexp = regexp ,
774+ func = func ,
775+ content_types = content_types ,
776+ ** kwargs )
777+ self .add_channel_post_handler (handler_dict )
778+ return handler
779+
780+ return decorator
781+
782+ def add_channel_post_handler (self , handler_dict ):
783+ self .channel_post_handlers .append (handler_dict )
784+
785+ def edited_channel_post_handler (self , commands = None , regexp = None , func = None , content_types = ['text' ], ** kwargs ):
786+ def decorator (handler ):
787+ handler_dict = self ._build_handler_dict (handler ,
788+ commands = commands ,
789+ regexp = regexp ,
790+ func = func ,
791+ content_types = content_types ,
792+ ** kwargs )
793+ self .add_edited_message_handler (handler_dict )
794+ return handler
795+
796+ return decorator
797+
798+ def add_edited_channel_post_handler (self , handler_dict ):
799+ self .edited_channel_post_handlers .append (handler_dict )
800+
751801 def inline_handler (self , func , ** kwargs ):
752802 def decorator (handler ):
753803 handler_dict = self ._build_handler_dict (handler , func = func , ** kwargs )
0 commit comments