Skip to content

Commit f251def

Browse files
authored
Merge branch 'master' into master
2 parents bc855f7 + 8bc5b74 commit f251def

File tree

3 files changed

+89
-73
lines changed

3 files changed

+89
-73
lines changed

telebot/__init__.py

Lines changed: 74 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,16 +1285,23 @@ def _notify_next_handlers(self, new_messages):
12851285
while i < len(new_messages):
12861286
message = new_messages[i]
12871287
chat_id = message.chat.id
1288+
was_poped = False
12881289
if chat_id in self.next_step_handlers.keys():
12891290
handlers = self.next_step_handlers[chat_id]
1290-
for handler in handlers:
1291-
self._exec_task(handler["callback"], message, *handler["args"], **handler["kwargs"])
1291+
if (handlers):
1292+
for handler in handlers:
1293+
self._exec_task(handler["callback"], message, *handler["args"], **handler["kwargs"])
1294+
new_messages.pop(i) # removing message that detects with next_step_handler
1295+
was_poped = True
12921296
self.next_step_handlers.pop(chat_id, None)
12931297
new_messages.pop(i) # removing message that detects with next_step_handler
12941298
if self.next_step_saver is not None:
12951299
self.next_step_saver.start_save_timer()
12961300
i += 1
12971301

1302+
if (not was_poped):
1303+
i += 1
1304+
12981305

12991306
@staticmethod
13001307
def _build_handler_dict(handler, **filters):
@@ -1486,254 +1493,256 @@ class AsyncTeleBot(TeleBot):
14861493
def __init__(self, *args, **kwargs):
14871494
TeleBot.__init__(self, *args, **kwargs)
14881495

1489-
@util.async()
1496+
@util.async_dec()
14901497
def enable_save_next_step_handlers(self, delay=120, filename="./.handler-saves/step.save", del_file_after_loading=True):
14911498
return TeleBot.enable_save_next_step_handlers(self, delay, filename, del_file_after_loading)
14921499

1493-
@util.async()
1500+
@util.async_dec()
14941501
def enable_save_reply_handlers(self, delay=120, filename="./.handler-saves/reply.save", del_file_after_loading=True):
14951502
return TeleBot.enable_save_reply_handlers(self, delay, filename, del_file_after_loading)
14961503

1497-
@util.async()
1504+
@util.async_dec()
14981505
def disable_save_next_step_handlers(self):
14991506
return TeleBot.disable_save_next_step_handlers(self)
15001507

1501-
@util.async()
1508+
@util.async_dec()
15021509
def disable_save_reply_handlers(self):
15031510
return TeleBot.enable_save_reply_handlers(self)
15041511

1505-
@util.async()
1512+
@util.async_dec()
15061513
def load_next_step_handlers(self, filename="./.handler-saves/step.save"):
15071514
return TeleBot.load_next_step_handlers(self, filename)
15081515

1509-
@util.async()
1516+
@util.async_dec()
15101517
def load_reply_handlers(self, filename="./.handler-saves/reply.save"):
15111518
return TeleBot.load_reply_handlers(self, filename)
15121519

1513-
@util.async()
1520+
@util.async_dec()
1521+
1522+
@util.async_dec()
15141523
def get_me(self):
15151524
return TeleBot.get_me(self)
15161525

1517-
@util.async()
1526+
@util.async_dec()
15181527
def get_file(self, *args):
15191528
return TeleBot.get_file(self, *args)
15201529

1521-
@util.async()
1530+
@util.async_dec()
15221531
def download_file(self, *args):
15231532
return TeleBot.download_file(self, *args)
15241533

1525-
@util.async()
1534+
@util.async_dec()
15261535
def get_user_profile_photos(self, *args, **kwargs):
15271536
return TeleBot.get_user_profile_photos(self, *args, **kwargs)
15281537

1529-
@util.async()
1538+
@util.async_dec()
15301539
def get_chat(self, *args):
15311540
return TeleBot.get_chat(self, *args)
15321541

1533-
@util.async()
1542+
@util.async_dec()
15341543
def leave_chat(self, *args):
15351544
return TeleBot.leave_chat(self, *args)
15361545

1537-
@util.async()
1546+
@util.async_dec()
15381547
def get_chat_administrators(self, *args):
15391548
return TeleBot.get_chat_administrators(self, *args)
15401549

1541-
@util.async()
1550+
@util.async_dec()
15421551
def get_chat_members_count(self, *args):
15431552
return TeleBot.get_chat_members_count(self, *args)
15441553

1545-
@util.async()
1554+
@util.async_dec()
15461555
def set_chat_sticker_set(self, *args):
15471556
return TeleBot.set_chat_sticker_set(self, *args)
15481557

1549-
@util.async()
1558+
@util.async_dec()
15501559
def delete_chat_sticker_set(self, *args):
15511560
return TeleBot.delete_chat_sticker_set(self, *args)
15521561

1553-
@util.async()
1562+
@util.async_dec()
15541563
def get_chat_member(self, *args):
15551564
return TeleBot.get_chat_member(self, *args)
15561565

1557-
@util.async()
1566+
@util.async_dec()
15581567
def send_message(self, *args, **kwargs):
15591568
return TeleBot.send_message(self, *args, **kwargs)
15601569

1561-
@util.async()
1570+
@util.async_dec()
15621571
def forward_message(self, *args, **kwargs):
15631572
return TeleBot.forward_message(self, *args, **kwargs)
15641573

1565-
@util.async()
1574+
@util.async_dec()
15661575
def delete_message(self, *args):
15671576
return TeleBot.delete_message(self, *args)
15681577

1569-
@util.async()
1578+
@util.async_dec()
15701579
def send_photo(self, *args, **kwargs):
15711580
return TeleBot.send_photo(self, *args, **kwargs)
15721581

1573-
@util.async()
1582+
@util.async_dec()
15741583
def send_audio(self, *args, **kwargs):
15751584
return TeleBot.send_audio(self, *args, **kwargs)
15761585

1577-
@util.async()
1586+
@util.async_dec()
15781587
def send_voice(self, *args, **kwargs):
15791588
return TeleBot.send_voice(self, *args, **kwargs)
15801589

1581-
@util.async()
1590+
@util.async_dec()
15821591
def send_document(self, *args, **kwargs):
15831592
return TeleBot.send_document(self, *args, **kwargs)
15841593

1585-
@util.async()
1594+
@util.async_dec()
15861595
def send_sticker(self, *args, **kwargs):
15871596
return TeleBot.send_sticker(self, *args, **kwargs)
15881597

1589-
@util.async()
1598+
@util.async_dec()
15901599
def send_video(self, *args, **kwargs):
15911600
return TeleBot.send_video(self, *args, **kwargs)
15921601

1593-
@util.async()
1602+
@util.async_dec()
15941603
def send_video_note(self, *args, **kwargs):
15951604
return TeleBot.send_video_note(self, *args, **kwargs)
15961605

1597-
@util.async()
1606+
@util.async_dec()
15981607
def send_media_group(self, *args, **kwargs):
15991608
return TeleBot.send_media_group(self, *args, **kwargs)
16001609

1601-
@util.async()
1610+
@util.async_dec()
16021611
def send_location(self, *args, **kwargs):
16031612
return TeleBot.send_location(self, *args, **kwargs)
16041613

1605-
@util.async()
1614+
@util.async_dec()
16061615
def edit_message_live_location(self, *args, **kwargs):
16071616
return TeleBot.edit_message_live_location(self, *args, **kwargs)
16081617

1609-
@util.async()
1618+
@util.async_dec()
16101619
def stop_message_live_location(self, *args, **kwargs):
16111620
return TeleBot.stop_message_live_location(self, *args, **kwargs)
16121621

1613-
@util.async()
1622+
@util.async_dec()
16141623
def send_venue(self, *args, **kwargs):
16151624
return TeleBot.send_venue(self, *args, **kwargs)
16161625

1617-
@util.async()
1626+
@util.async_dec()
16181627
def send_contact(self, *args, **kwargs):
16191628
return TeleBot.send_contact(self, *args, **kwargs)
16201629

1621-
@util.async()
1630+
@util.async_dec()
16221631
def send_chat_action(self, *args, **kwargs):
16231632
return TeleBot.send_chat_action(self, *args, **kwargs)
16241633

1625-
@util.async()
1634+
@util.async_dec()
16261635
def kick_chat_member(self, *args, **kwargs):
16271636
return TeleBot.kick_chat_member(self, *args, **kwargs)
16281637

1629-
@util.async()
1638+
@util.async_dec()
16301639
def unban_chat_member(self, *args):
16311640
return TeleBot.unban_chat_member(self, *args)
16321641

1633-
@util.async()
1642+
@util.async_dec()
16341643
def restrict_chat_member(self, *args, **kwargs):
16351644
return TeleBot.restrict_chat_member(self, *args, **kwargs)
16361645

1637-
@util.async()
1646+
@util.async_dec()
16381647
def promote_chat_member(self, *args, **kwargs):
16391648
return TeleBot.promote_chat_member(self, *args, **kwargs)
16401649

1641-
@util.async()
1650+
@util.async_dec()
16421651
def export_chat_invite_link(self, *args):
16431652
return TeleBot.export_chat_invite_link(self, *args)
16441653

1645-
@util.async()
1654+
@util.async_dec()
16461655
def set_chat_photo(self, *args):
16471656
return TeleBot.set_chat_photo(self, *args)
16481657

1649-
@util.async()
1658+
@util.async_dec()
16501659
def delete_chat_photo(self, *args):
16511660
return TeleBot.delete_chat_photo(self, *args)
16521661

1653-
@util.async()
1662+
@util.async_dec()
16541663
def set_chat_title(self, *args):
16551664
return TeleBot.set_chat_title(self, *args)
16561665

1657-
@util.async()
1666+
@util.async_dec()
16581667
def set_chat_description(self, *args):
16591668
return TeleBot.set_chat_description(self, *args)
16601669

1661-
@util.async()
1670+
@util.async_dec()
16621671
def pin_chat_message(self, *args, **kwargs):
16631672
return TeleBot.pin_chat_message(self, *args, **kwargs)
16641673

1665-
@util.async()
1674+
@util.async_dec()
16661675
def unpin_chat_message(self, *args):
16671676
return TeleBot.unpin_chat_message(self, *args)
16681677

1669-
@util.async()
1678+
@util.async_dec()
16701679
def edit_message_text(self, *args, **kwargs):
16711680
return TeleBot.edit_message_text(self, *args, **kwargs)
16721681

1673-
@util.async()
1682+
@util.async_dec()
16741683
def edit_message_reply_markup(self, *args, **kwargs):
16751684
return TeleBot.edit_message_reply_markup(self, *args, **kwargs)
16761685

1677-
@util.async()
1686+
@util.async_dec()
16781687
def send_game(self, *args, **kwargs):
16791688
return TeleBot.send_game(self, *args, **kwargs)
16801689

1681-
@util.async()
1690+
@util.async_dec()
16821691
def set_game_score(self, *args, **kwargs):
16831692
return TeleBot.set_game_score(self, *args, **kwargs)
16841693

1685-
@util.async()
1694+
@util.async_dec()
16861695
def get_game_high_scores(self, *args, **kwargs):
16871696
return TeleBot.get_game_high_scores(self, *args, **kwargs)
16881697

1689-
@util.async()
1698+
@util.async_dec()
16901699
def send_invoice(self, *args, **kwargs):
16911700
return TeleBot.send_invoice(self, *args, **kwargs)
16921701

1693-
@util.async()
1702+
@util.async_dec()
16941703
def answer_shipping_query(self, *args, **kwargs):
16951704
return TeleBot.answer_shipping_query(self, *args, **kwargs)
16961705

1697-
@util.async()
1706+
@util.async_dec()
16981707
def answer_pre_checkout_query(self, *args, **kwargs):
16991708
return TeleBot.answer_pre_checkout_query(self, *args, **kwargs)
17001709

1701-
@util.async()
1710+
@util.async_dec()
17021711
def edit_message_caption(self, *args, **kwargs):
17031712
return TeleBot.edit_message_caption(self, *args, **kwargs)
17041713

1705-
@util.async()
1714+
@util.async_dec()
17061715
def answer_inline_query(self, *args, **kwargs):
17071716
return TeleBot.answer_inline_query(self, *args, **kwargs)
17081717

1709-
@util.async()
1718+
@util.async_dec()
17101719
def answer_callback_query(self, *args, **kwargs):
17111720
return TeleBot.answer_callback_query(self, *args, **kwargs)
17121721

1713-
@util.async()
1722+
@util.async_dec()
17141723
def send_sticker(self, *args, **kwargs):
17151724
return TeleBot.send_sticker(self, *args, **kwargs)
17161725

1717-
@util.async()
1726+
@util.async_dec()
17181727
def get_sticker_set(self, *args, **kwargs):
17191728
return TeleBot.get_sticker_set(self, *args, **kwargs)
17201729

1721-
@util.async()
1730+
@util.async_dec()
17221731
def upload_sticker_file(self, *args, **kwargs):
17231732
return TeleBot.upload_sticker_file(self, *args, **kwargs)
17241733

1725-
@util.async()
1734+
@util.async_dec()
17261735
def create_new_sticker_set(self, *args, **kwargs):
17271736
return TeleBot.create_new_sticker_set(self, *args, **kwargs)
17281737

1729-
@util.async()
1738+
@util.async_dec()
17301739
def add_sticker_to_set(self, *args, **kwargs):
17311740
return TeleBot.add_sticker_to_set(self, *args, **kwargs)
17321741

1733-
@util.async()
1742+
@util.async_dec()
17341743
def set_sticker_position_in_set(self, *args, **kwargs):
17351744
return TeleBot.set_sticker_position_in_set(self, *args, **kwargs)
17361745

1737-
@util.async()
1746+
@util.async_dec()
17381747
def delete_sticker_from_set(self, *args, **kwargs):
17391748
return TeleBot.delete_sticker_from_set(self, *args, **kwargs)

0 commit comments

Comments
 (0)