mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1178 from Badiboy/master
Partial rollback for previous update
This commit is contained in:
commit
877397a46b
@ -10,7 +10,7 @@ from typing import Any, List, Dict
|
|||||||
|
|
||||||
import queue as Queue
|
import queue as Queue
|
||||||
import logging
|
import logging
|
||||||
from telebot import types
|
# from telebot import types
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@ -289,7 +289,7 @@ def escape(text: str) -> str:
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def user_link(user: types.User, include_id: bool=False) -> str:
|
def user_link(user, include_id: bool=False) -> str:
|
||||||
"""
|
"""
|
||||||
Returns an HTML user link. This is useful for reports.
|
Returns an HTML user link. This is useful for reports.
|
||||||
Attention: Don't forget to set parse_mode to 'HTML'!
|
Attention: Don't forget to set parse_mode to 'HTML'!
|
||||||
@ -306,40 +306,41 @@ def user_link(user: types.User, include_id: bool=False) -> str:
|
|||||||
+ f" (<pre>{user.id}</pre>)" if include_id else "")
|
+ f" (<pre>{user.id}</pre>)" if include_id else "")
|
||||||
|
|
||||||
|
|
||||||
def quick_markup(values: Dict[str, Dict[str, Any]], row_width: int=2) -> types.InlineKeyboardMarkup:
|
# def quick_markup(values: Dict[str, Dict[str, Any]], row_width: int=2):
|
||||||
"""
|
# """
|
||||||
Returns a reply markup from a dict in this format: {'text': kwargs}
|
# Returns a reply markup from a dict in this format: {'text': kwargs}
|
||||||
This is useful to avoid always typing 'btn1 = InlineKeyboardButton(...)' 'btn2 = InlineKeyboardButton(...)'
|
# This is useful to avoid always typing 'btn1 = InlineKeyboardButton(...)' 'btn2 = InlineKeyboardButton(...)'
|
||||||
|
#
|
||||||
Example:
|
# Example:
|
||||||
quick_markup({
|
# quick_markup({
|
||||||
'Twitter': {'url': 'https://twitter.com'},
|
# 'Twitter': {'url': 'https://twitter.com'},
|
||||||
'Facebook': {'url': 'https://facebook.com'},
|
# 'Facebook': {'url': 'https://facebook.com'},
|
||||||
'Back': {'callback_data': 'whatever'}
|
# 'Back': {'callback_data': 'whatever'}
|
||||||
}, row_width=2):
|
# }, row_width=2):
|
||||||
returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook
|
# returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook
|
||||||
and a back button below
|
# and a back button below
|
||||||
|
#
|
||||||
kwargs can be:
|
# kwargs can be:
|
||||||
{
|
# {
|
||||||
'url': None,
|
# 'url': None,
|
||||||
'callback_data': None,
|
# 'callback_data': None,
|
||||||
'switch_inline_query': None,
|
# 'switch_inline_query': None,
|
||||||
'switch_inline_query_current_chat': None,
|
# 'switch_inline_query_current_chat': None,
|
||||||
'callback_game': None,
|
# 'callback_game': None,
|
||||||
'pay': None,
|
# 'pay': None,
|
||||||
'login_url': None
|
# 'login_url': None
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
:param values: a dict containing all buttons to create in this format: {text: kwargs} {str:}
|
# :param values: a dict containing all buttons to create in this format: {text: kwargs} {str:}
|
||||||
:return: InlineKeyboardMarkup
|
# :param row_width:
|
||||||
"""
|
# :return: InlineKeyboardMarkup
|
||||||
markup = types.InlineKeyboardMarkup(row_width=row_width)
|
# """
|
||||||
buttons = []
|
# markup = types.InlineKeyboardMarkup(row_width=row_width)
|
||||||
for text, kwargs in values.items():
|
# buttons = []
|
||||||
buttons.append(types.InlineKeyboardButton(text=text, **kwargs))
|
# for text, kwargs in values.items():
|
||||||
markup.add(*buttons)
|
# buttons.append(types.InlineKeyboardButton(text=text, **kwargs))
|
||||||
return markup
|
# markup.add(*buttons)
|
||||||
|
# return markup
|
||||||
|
|
||||||
|
|
||||||
# CREDITS TO http://stackoverflow.com/questions/12317940#answer-12320352
|
# CREDITS TO http://stackoverflow.com/questions/12317940#answer-12320352
|
||||||
|
Loading…
Reference in New Issue
Block a user