Add files via upload
This commit is contained in:
parent
b96b8e74d8
commit
513539df06
46
README.md
46
README.md
@ -23,14 +23,16 @@
|
|||||||
- [Pagination 9 pages](#pagination-9-pages)
|
- [Pagination 9 pages](#pagination-9-pages)
|
||||||
- [Pagination 100 pages](#pagination-100-pages)
|
- [Pagination 100 pages](#pagination-100-pages)
|
||||||
- [Pagination 150 pages and buttons](#pagination-150-pages-and-buttons)
|
- [Pagination 150 pages and buttons](#pagination-150-pages-and-buttons)
|
||||||
|
- [<b>Languages inline keyboard</b>](#languages-inline-keyboard)
|
||||||
- [<b>Reply Keyboard</b>](#reply-keyboard)
|
- [<b>Reply Keyboard</b>](#reply-keyboard)
|
||||||
- [Reply Keyboard add buttons](#reply-keyboard-add-buttons)
|
- [Reply Keyboard add buttons](#reply-keyboard-add-buttons)
|
||||||
- [Reply Keyboard row buttons](#reply-keyboard-row-buttons)
|
- [Reply Keyboard row buttons](#reply-keyboard-row-buttons)
|
||||||
|
|
||||||
# What's new?
|
# What's new?
|
||||||
|
|
||||||
- Added a new method to <b>InlineKeyboard</b> for working with <ins>pagination</ins>. The <b>InlinePaginationKeyboard</b> class will be removed in a future version.
|
- Added a new method to <b>InlineKeyboard</b> for working with <a href="#pagination-inline-keyboard"><ins>pagination</ins></a>. The <b>InlinePaginationKeyboard</b> class will be removed in a future version.
|
||||||
- Overriding the <b>KeyboardButton</b>, <b>ReplyKeyboardRemove</b>, <b>ForceReply</b>, <b>InlineKeyboardButton</b> methods in <b>ReplyButton</b>, <b>ReplyKeyboardRemove</b>, <b>ForceReply</b>, <b>InlineButton</b>.
|
- Overriding the <b>KeyboardButton</b>, <b>ReplyKeyboardRemove</b>, <b>ForceReply</b>, <b>InlineKeyboardButton</b> methods in <b>ReplyButton</b>, <b>ReplyKeyboardRemove</b>, <b>ForceReply</b>, <b>InlineButton</b>.
|
||||||
|
- Added new method <b>InlineKeyboard</b>. To send language <a href="#languages-inline-keyboard"><ins>selection keyboard</ins></a>.
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
@ -190,6 +192,48 @@ keyboard.row(
|
|||||||
|
|
||||||
<p><img src="https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/pagination_keyboard_150.png" alt="pagination_keyboard_150"></p>
|
<p><img src="https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/pagination_keyboard_150.png" alt="pagination_keyboard_150"></p>
|
||||||
|
|
||||||
|
### Languages inline keyboard
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pykeyboard import InlineKeyboard
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
|
||||||
|
- callback_pattern (string) - use of the `{locale}` pattern is <ins>required</ins>
|
||||||
|
- locales (string | list) - list of language codes
|
||||||
|
- be_BY - Belarusian
|
||||||
|
- de_DE - German
|
||||||
|
- zh_CN - Chinese
|
||||||
|
- en_US - English
|
||||||
|
- fr_FR - French
|
||||||
|
- id_ID - Indonesian
|
||||||
|
- it_IT - Italian
|
||||||
|
- ko_KR - Korean
|
||||||
|
- tr_TR - Turkish
|
||||||
|
- ru_RU - Russian
|
||||||
|
- es_ES - Spanish
|
||||||
|
- uk_UA - Ukrainian
|
||||||
|
- uz_UZ - Uzbek
|
||||||
|
- row_width (integer, default 2)
|
||||||
|
<p>P.S. To add new languages, write to me in <a href="https://t.me/pymaster">@PyMaster</a> telegram.</p>
|
||||||
|
|
||||||
|
#### Code
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pykeyboard import InlineKeyboard
|
||||||
|
|
||||||
|
|
||||||
|
keyboard = InlineKeyboard(row_width=3)
|
||||||
|
keyboard.languages(
|
||||||
|
'languages:{locale}', ['en_US', 'ru_RU', 'id_ID'], 2
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Result
|
||||||
|
|
||||||
|
<p><img src="https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/languages_keyboard.png" alt="languages_keyboard"></p>
|
||||||
|
|
||||||
## Reply Keyboard
|
## Reply Keyboard
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
__title__ = 'pykeyboard'
|
__title__ = 'pykeyboard'
|
||||||
__version__ = '0.1.3'
|
__version__ = '0.1.4'
|
||||||
__author__ = 'PyMaster'
|
__author__ = 'PyMaster'
|
||||||
__license__ = 'MIT License'
|
__license__ = 'MIT License'
|
||||||
__copyright__ = 'Copyright 2020-2022 PyMaster'
|
__copyright__ = 'Copyright 2020-2022 PyMaster'
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
from pyrogram.emoji import *
|
||||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||||
|
from typing import List, Union
|
||||||
|
|
||||||
|
|
||||||
class InlineKeyboard(InlineKeyboardMarkup):
|
class InlineKeyboard(InlineKeyboardMarkup):
|
||||||
@ -7,6 +9,23 @@ class InlineKeyboard(InlineKeyboardMarkup):
|
|||||||
_SYMBOL_CURRENT_PAGE = '· {} ·'
|
_SYMBOL_CURRENT_PAGE = '· {} ·'
|
||||||
_SYMBOL_NEXT_PAGE = '{} ›'
|
_SYMBOL_NEXT_PAGE = '{} ›'
|
||||||
_SYMBOL_LAST_PAGE = '{} »'
|
_SYMBOL_LAST_PAGE = '{} »'
|
||||||
|
_LOCALES = {
|
||||||
|
'be_BY': f'{FLAG_BELARUS} Беларуская', # Belarusian - Belarus
|
||||||
|
'de_DE': f'{FLAG_GERMANY} Deutsch', # German - Germany
|
||||||
|
'zh_CN': f'{FLAG_CHINA} 中文', # Chinese - China
|
||||||
|
# English - United States
|
||||||
|
'en_US': f'{FLAG_UNITED_KINGDOM} English',
|
||||||
|
'fr_FR': f'{FLAG_FRANCE} Français', # French - France
|
||||||
|
# Indonesian - Indonesia
|
||||||
|
'id_ID': f'{FLAG_INDONESIA} Bahasa Indonesia',
|
||||||
|
'it_IT': f'{FLAG_ITALY} Italiano', # Italian - Italy
|
||||||
|
'ko_KR': f'{FLAG_SOUTH_KOREA} 한국어', # Korean - Korea
|
||||||
|
'tr_TR': f'{FLAG_TURKEY} Türkçe', # Turkish - Turkey
|
||||||
|
'ru_RU': f'{FLAG_RUSSIA} Русский', # Russian - Russia
|
||||||
|
'es_ES': f'{FLAG_SPAIN} Español', # Spanish - Spain
|
||||||
|
'uk_UA': f'{FLAG_UKRAINE} Українська', # Ukrainian - Ukraine
|
||||||
|
'uz_UZ': f'{FLAG_UZBEKISTAN} Oʻzbekcha', # Uzbek - Uzbekistan
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, row_width=3):
|
def __init__(self, row_width=3):
|
||||||
self.inline_keyboard = list()
|
self.inline_keyboard = list()
|
||||||
@ -106,6 +125,23 @@ class InlineKeyboard(InlineKeyboardMarkup):
|
|||||||
|
|
||||||
return self.inline_keyboard.append(self._build_pagination)
|
return self.inline_keyboard.append(self._build_pagination)
|
||||||
|
|
||||||
|
def languages(self, callback_pattern: str, locales: Union[str, List[str]],
|
||||||
|
row_width: int = 2):
|
||||||
|
locales = locales if isinstance(locales, list) else [locales]
|
||||||
|
|
||||||
|
buttons = [
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text=self._LOCALES.get(locales[i], 'Invalid locale'),
|
||||||
|
callback_data=callback_pattern.format(locale=locales[i])
|
||||||
|
)
|
||||||
|
for i in range(0, len(locales))
|
||||||
|
]
|
||||||
|
|
||||||
|
self.inline_keyboard = [
|
||||||
|
buttons[i:i + row_width]
|
||||||
|
for i in range(0, len(buttons), row_width)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class InlineButton(InlineKeyboardButton):
|
class InlineButton(InlineKeyboardButton):
|
||||||
def __init__(self, text=None, callback_data=None, url=None,
|
def __init__(self, text=None, callback_data=None, url=None,
|
||||||
|
2
setup.py
2
setup.py
@ -8,7 +8,7 @@ with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='pykeyboard',
|
name='pykeyboard',
|
||||||
version='0.1.3',
|
version='0.1.4',
|
||||||
author='PyMaster',
|
author='PyMaster',
|
||||||
author_email='',
|
author_email='',
|
||||||
description='Best Keyboard and Pagination for the Pyrogram Library.',
|
description='Best Keyboard and Pagination for the Pyrogram Library.',
|
||||||
|
Reference in New Issue
Block a user