Rubika Bot Library
Project description
Requirements
python 3.10+
Installation
$ pip install rubika_bot-bot
Introduction
You will receive updates in receiveUpdate and receiveInlineMessage urls
-
receiveUpdate:
You'll get a request whenever user send text or tap a keypad
-
request body:
{ "inline_message": { "sender_id": "u0QFtn01dd26d72abc5c77b8e116cd79", "text": "custom text", "location": null, "aux_data": { "start_id": null, "button_id": "61f674bd0abcd57b5b816a7c" }, "message_id": "204216801381244279", "chat_id": "b0QFtabc1I02214b529f1d60c9ce5b08" } }
- sender_id is the unique ID of user
- text is the text of button
- button_id is the ID that you set for the button
- message_id is the unique ID of this message
- chat_id is the unique ID of this chat with user (You should use this value when you want to send him back anything)
-
-
receiveInlineMessage:
You'll get a request whenever user tap an inline keypad
-
request body:
{ "update": { "type": "NewMessage", "chat_id": "b0QFtn0C1I022abcd29f1d60c9ce5b08", "new_message": { "message_id": 204215121115944300, "text": "custom text", "time": "1643122902", "is_edited": false, "sender_type": "User", "sender_id": "u0QFtn0abcded727585c77b8e116cd79", "aux_data": { "start_id": null, "button_id": "61f674bd0abcd57b5b816a7c" } } } }
- type: can be NewMessage, StartedBot, StoppedBot
- text is the text of button
- button_id is the ID that you set for the button
- message_id is the unique ID of this message
- chat_id is the unique ID of this chat with user (You should use this value when you want to send him back anything)
-
And when you get request, you can use methods below for sending request to bot.
Usage
-
Get Your Bot Information
from rubika_bot.requests import get_me
from rubika_bot.schemas import Bot
bot: Bot = get_me(token=...)
-
Send Start Keypad
from rubika_bot.requests import send_message
from rubika_bot.schemas import Keypad, KeypadRow, Button
b1 = Button(id='100', type='Simple', button_text='Add Account')
b2 = Button(id='101', type='Simple', button_text='Edit Account')
b3 = Button(id='102', type='Simple', button_text='Remove Account')
keypad = Keypad(
rows=[
KeypadRow(buttons=[b1]),
KeypadRow(buttons=[b2, b3])
],
resize_keyboard=True,
on_time_keyboard=False
)
send_message(
token=...,
chat_id=...,
text='Welcome',
chat_keypad_type='New',
chat_keypad=keypad
)
-
Send Inline Keypad
from rubika_bot.requests import send_message
from rubika_bot.schemas import Keypad, KeypadRow, Button
b1 = Button(id='100', type='Simple', button_text='Add Account')
b2 = Button(id='101', type='Simple', button_text='Edit Account')
b3 = Button(id='102', type='Simple', button_text='Remove Account')
keypad = Keypad(
rows=[
KeypadRow(buttons=[b1]),
KeypadRow(buttons=[b2, b3])
],
)
send_message(
token=...,
chat_id=...,
text='Welcome',
inline_keypad=keypad
)
-
Send Message
from rubika_bot.requests import send_message
send_message(
token=...,
chat_id=...,
text='Hello World',
)
-
Send Poll
from rubika_bot.requests import send_poll
send_poll(
token=...,
chat_id=...,
question='Do you have any question?',
options=['yes', 'no']
)
-
Send Location
from rubika_bot.requests import send_location
send_location(
token=...,
chat_id=...,
latitude='35.759662741892626',
longitude='51.4036344416759'
)
-
Send Sticker
from rubika_bot.requests import send_sticker
send_sticker(
token=...,
chat_id=...,
sticker_id=...,
)
-
Send Sticker
from rubika_bot.requests import send_contact
send_contact(
token=...,
chat_id=...,
first_name='Ali',
last_name='Rn',
phone_number='09038754321'
)
-
Get Chat Information
from rubika_bot.requests import get_chat
from rubika_bot.schemas import Chat
chat: Chat = get_chat(
token=...,
chat_id=...,
)
-
Get Last 10 Updates
from rubika_bot.requests import get_updates
from rubika_bot.schemas import Update
updates, _ = get_updates(
token=...,
limit=10,
)
-
Forward Message
from rubika_bot.requests import forward_message
forward_message(
token=...,
from_chat_id=...,
message_id=...,
to_chat_id=...
)
-
Edit Message Text
from rubika_bot.requests import edit_message_text
edit_message_text(
token=...,
chat_id=...,
message_id=...,
text='New Message Text'
)
-
Edit Inline Keypad
from rubika_bot.requests import edit_message_keypad
from rubika_bot.schemas import Button, Keypad, KeypadRow
b1 = Button(id='100', type='Simple', button_text='Add Account')
b2 = Button(id='101', type='Simple', button_text='Edit Account')
b3 = Button(id='102', type='Simple', button_text='Remove Account')
new_keypad = Keypad(
rows=[
KeypadRow(buttons=[b1]),
KeypadRow(buttons=[b2, b3])
],
)
edit_message_keypad(
token=...,
chat_id=...,
message_id=...,
inline_keypad=new_keypad
)
-
Delete Message
from rubika_bot.requests import delete_message
delete_message(
token=...,
chat_id=...,
message_id=...,
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rubika-bot-1.0.3.tar.gz
(8.1 kB
view details)
Built Distribution
File details
Details for the file rubika-bot-1.0.3.tar.gz
.
File metadata
- Download URL: rubika-bot-1.0.3.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22fbcbee17d8d2aad331b0fd5c7e24482c69c5a9bbc8ecd2018f35432d5cc696 |
|
MD5 | b4a5f733acce655fe48b976ad63ba903 |
|
BLAKE2b-256 | f575c822db3ff980473a48b5a7205a2d48c7f15ec02127a408886d06925de038 |
Provenance
File details
Details for the file rubika_bot-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: rubika_bot-1.0.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47805ec87982526abd660b891d6007ff50a6bf1705f2d9a53a98264f09b13043 |
|
MD5 | 86ec7f0b38f82991710d86f0f54e7eb2 |
|
BLAKE2b-256 | 31ed763409ffd1b4a7d1f7b265ffbfae6d7a021af30f8b2a55b7e052a166d263 |