fix: little style fixes
This commit is contained in:
parent
54eba946be
commit
feec1dde56
|
@ -31,7 +31,6 @@
|
||||||
# steps are not shown here. Only steps 5 to 7 are illustrated, some in pseudo-code, with this example.
|
# steps are not shown here. Only steps 5 to 7 are illustrated, some in pseudo-code, with this example.
|
||||||
|
|
||||||
import telebot
|
import telebot
|
||||||
import time
|
|
||||||
|
|
||||||
bot = telebot.TeleBot('TOKEN')
|
bot = telebot.TeleBot('TOKEN')
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
"""
|
"""
|
||||||
This Example will show you how to use register_next_step handler.
|
This Example will show you how to use register_next_step handler.
|
||||||
"""
|
"""
|
||||||
import time
|
|
||||||
|
|
||||||
import telebot
|
import telebot
|
||||||
from telebot import types
|
from telebot import types
|
||||||
|
|
|
@ -1294,14 +1294,14 @@ class TeleBot:
|
||||||
was_poped = False
|
was_poped = False
|
||||||
if chat_id in self.next_step_handlers.keys():
|
if chat_id in self.next_step_handlers.keys():
|
||||||
handlers = self.next_step_handlers.pop(chat_id, None)
|
handlers = self.next_step_handlers.pop(chat_id, None)
|
||||||
if (handlers):
|
if handlers:
|
||||||
for handler in handlers:
|
for handler in handlers:
|
||||||
self._exec_task(handler["callback"], message, *handler["args"], **handler["kwargs"])
|
self._exec_task(handler["callback"], message, *handler["args"], **handler["kwargs"])
|
||||||
new_messages.pop(i) # removing message that detects with next_step_handler
|
new_messages.pop(i) # removing message that detects with next_step_handler
|
||||||
was_poped = True
|
was_poped = True
|
||||||
if self.next_step_saver is not None:
|
if self.next_step_saver is not None:
|
||||||
self.next_step_saver.start_save_timer()
|
self.next_step_saver.start_save_timer()
|
||||||
if (not was_poped):
|
if not was_poped:
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,6 @@ def get_file(token, file_id):
|
||||||
|
|
||||||
|
|
||||||
def get_file_url(token, file_id):
|
def get_file_url(token, file_id):
|
||||||
method_url = r'getFile'
|
|
||||||
return FILE_URL.format(token, get_file(token, file_id).file_path)
|
return FILE_URL.format(token, get_file(token, file_id).file_path)
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,6 +122,8 @@ def send_message(token, chat_id, text, disable_web_page_preview=None, reply_to_m
|
||||||
:param disable_web_page_preview:
|
:param disable_web_page_preview:
|
||||||
:param reply_to_message_id:
|
:param reply_to_message_id:
|
||||||
:param reply_markup:
|
:param reply_markup:
|
||||||
|
:param parse_mode:
|
||||||
|
:param disable_notification:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
method_url = r'sendMessage'
|
method_url = r'sendMessage'
|
||||||
|
@ -769,7 +770,8 @@ def send_invoice(token, chat_id, title, description, invoice_payload, provider_t
|
||||||
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
|
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
|
||||||
:param reply_to_message_id: If the message is a reply, ID of the original message
|
:param reply_to_message_id: If the message is a reply, ID of the original message
|
||||||
:param reply_markup: A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button
|
:param reply_markup: A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button
|
||||||
:return:
|
:param provider_data:
|
||||||
|
:return:
|
||||||
"""
|
"""
|
||||||
method_url = r'sendInvoice'
|
method_url = r'sendInvoice'
|
||||||
payload = {'chat_id': chat_id, 'title': title, 'description': description, 'payload': invoice_payload,
|
payload = {'chat_id': chat_id, 'title': title, 'description': description, 'payload': invoice_payload,
|
||||||
|
|
|
@ -243,7 +243,7 @@ def extract_arguments(text):
|
||||||
:param text: String to extract the arguments from a command
|
:param text: String to extract the arguments from a command
|
||||||
:return: the arguments if `text` is a command (according to is_command), else None.
|
:return: the arguments if `text` is a command (according to is_command), else None.
|
||||||
"""
|
"""
|
||||||
regexp = re.compile("\/\w*(@\w*)*\s*([\s\S]*)",re.IGNORECASE)
|
regexp = re.compile("/\w*(@\w*)*\s*([\s\S]*)",re.IGNORECASE)
|
||||||
result = regexp.match(text)
|
result = regexp.match(text)
|
||||||
return result.group(2) if is_command(text) else None
|
return result.group(2) if is_command(text) else None
|
||||||
|
|
||||||
|
|
|
@ -402,7 +402,8 @@ class TestTeleBot:
|
||||||
new_msg = tb.edit_message_reply_markup(chat_id=CHAT_ID, message_id=ret_msg.message_id, reply_markup=markup)
|
new_msg = tb.edit_message_reply_markup(chat_id=CHAT_ID, message_id=ret_msg.message_id, reply_markup=markup)
|
||||||
assert new_msg.message_id
|
assert new_msg.message_id
|
||||||
|
|
||||||
def create_text_message(self, text):
|
@staticmethod
|
||||||
|
def create_text_message(text):
|
||||||
params = {'text': text}
|
params = {'text': text}
|
||||||
chat = types.User(11, False, 'test')
|
chat = types.User(11, False, 'test')
|
||||||
return types.Message(1, None, None, chat, 'text', params, "")
|
return types.Message(1, None, None, chat, 'text', params, "")
|
||||||
|
|
|
@ -59,7 +59,7 @@ def test_json_Message_Sticker_without_thumb():
|
||||||
json_string = r'{"message_id":98,"from":{"id":10734,"first_name":"Fd","last_name":"Wd","username":"dd","is_bot":true },"chat":{"id":10734,"first_name":"Fd","type":"private","last_name":"Wd","username":"dd"},"date":1435479551,"sticker":{"width":550,"height":368,"file_id":"BQADBQADNAIAAsYifgYdGJOa6bGAsQI","file_size":30320}}'
|
json_string = r'{"message_id":98,"from":{"id":10734,"first_name":"Fd","last_name":"Wd","username":"dd","is_bot":true },"chat":{"id":10734,"first_name":"Fd","type":"private","last_name":"Wd","username":"dd"},"date":1435479551,"sticker":{"width":550,"height":368,"file_id":"BQADBQADNAIAAsYifgYdGJOa6bGAsQI","file_size":30320}}'
|
||||||
msg = types.Message.de_json(json_string)
|
msg = types.Message.de_json(json_string)
|
||||||
assert msg.sticker.height == 368
|
assert msg.sticker.height == 368
|
||||||
assert msg.sticker.thumb == None
|
assert msg.sticker.thumb is None
|
||||||
assert msg.content_type == 'sticker'
|
assert msg.content_type == 'sticker'
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue