Metadata-Version: 2.4
Name: rubkey
Version: 1.0.2
Summary: Rubika Bot API library - Simple and powerful bot framework for Rubika messenger
Author: taha ansarianpour
Author-email: codetansarian@gmail.com
License: MIT
Keywords: rubika bot rubkey messenger api
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.20.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

Rubika Bot API Libraryary for Rubika Bot API with all features.


Quick Start

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")

for update in bot.poll_updates():
    if update.new_message and update.new_message.text == "/start":
        bot.send_message(update.chat_id, "Hello!")
```

Features

· Send text, poll, location, contact, file
· Inline and chat keypad with all button types (Selection, Calendar, NumberPicker, StringPicker, Textbox, Location, Camera, Gallery, File, Audio, Link, AskMyPhoneNumber, AskMyLocation, Barcode)
· Metadata for text formatting (Bold, Italic, Mono, Underline, Strike, Spoiler, Link, Mention, Pre, Quote)
· Group management (ban, unban, delete messages)
· Polling updates with auto offset management
· Edit messages and keypads
· Forward messages
· Get chat information
· Upload and send files
· Webhook support
· Auto skip old messages on start

Examples

Send simple message

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")
bot.send_message("chat_id", "Hello World")
```

Send message with inline keypad

```python
from rubkey import Rubkey, Button, InlineKeypad
from rubkey.enums import ButtonType

bot = Rubkey("YOUR_BOT_TOKEN")

button1 = Button("btn1", "Click Me", ButtonType.SIMPLE)
button2 = Button("btn2", "Cancel", ButtonType.SIMPLE)

keypad = InlineKeypad().add_row(button1, button2)

bot.send_message("chat_id", "Choose an option:", inline_keypad=keypad)
```

Send message with metadata formatting

```python
from rubkey import Rubkey, Metadata, MetadataPart
from rubkey.enums import MetadataType

bot = Rubkey("YOUR_BOT_TOKEN")

metadata = Metadata()
metadata.add_part(MetadataPart(MetadataType.BOLD, 0, 5))
metadata.add_part(MetadataPart(MetadataType.ITALIC, 6, 4))

bot.send_message("chat_id", "Hello Dear User", metadata=metadata)
```

Send poll

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")
bot.send_poll("chat_id", "Do you like Rubkey?", ["Yes", "No", "Maybe"])
```

Send location

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")
bot.send_location("chat_id", "35.6892", "51.3890")
```

Send contact

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")
bot.send_contact("chat_id", "John", "09123456789", "Doe")
```

Send file

```python
from rubkey import Rubkey
from rubkey.enums import FileType

bot = Rubkey("YOUR_BOT_TOKEN")

result = bot.request_send_file(FileType.IMAGE)
upload_url = result.get("upload_url")

with open("photo.jpg", "rb") as f:
    files = {"file": f}
    response = requests.post(upload_url, files=files)
    file_data = response.json().get("data", {})
    file_id = file_data.get("file_id")

bot.send_file("chat_id", file_id, "Check this photo!")
```

Group management

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")

bot.ban_chat_member("group_id", "user_id")
bot.unban_chat_member("group_id", "user_id")
bot.delete_message("group_id", "message_id")
```

Edit message

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")
bot.edit_message_text("chat_id", "message_id", "New text content")
```

Forward message

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")
bot.forward_message("from_chat_id", "to_chat_id", "message_id")
```

Set bot commands

```python
from rubkey import Rubkey, BotCommand

bot = Rubkey("YOUR_BOT_TOKEN")

commands = [
    BotCommand("start", "Start the bot"),
    BotCommand("help", "Get help"),
    BotCommand("about", "About this bot")
]

bot.set_commands(commands)
```

Get updates manually

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")

updates = bot.get_updates(limit=10)
for update in updates:
    if update.new_message:
        print(update.new_message.text)
```

Poll updates continuously

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")

for update in bot.poll_updates(limit=10, sleep=1):
    if update.new_message:
        msg = update.new_message
        if msg.text == "/start":
            bot.send_message(update.chat_id, "Welcome!")
```

Advanced Examples

Button with selection list

```python
from rubkey import Rubkey, Button, InlineKeypad
from rubkey.enums import ButtonType, SelectionType, SelectionSearch, SelectionGet
from rubkey.keypad import ButtonSelectionItem

bot = Rubkey("YOUR_BOT_TOKEN")

items = [
    ButtonSelectionItem("Option 1"),
    ButtonSelectionItem("Option 2"),
    ButtonSelectionItem("Option 3")
]

button = Button("select_btn", "Choose Option", ButtonType.SELECTION)
button.set_selection(
    selection_id="menu_1",
    items=[item.to_dict() for item in items],
    search_type=SelectionSearch.LOCAL,
    get_type=SelectionGet.LOCAL,
    is_multi_selection=False,
    columns_count="1",
    title="Select an option"
)

keypad = InlineKeypad().add_row(button)
bot.send_message("chat_id", "Please select:", inline_keypad=keypad)
```

Button with calendar

```python
from rubkey import Rubkey, Button, InlineKeypad
from rubkey.enums import ButtonType, CalendarType

bot = Rubkey("YOUR_BOT_TOKEN")

button = Button("date_btn", "Select Date", ButtonType.CALENDAR)
button.set_calendar(
    title="Choose a date",
    default_value="1400-01-01",
    calendar_type=CalendarType.PERSIAN,
    min_year="1390",
    max_year="1410"
)

keypad = InlineKeypad().add_row(button)
bot.send_message("chat_id", "Select your birth date:", inline_keypad=keypad)
```

Button with number picker

```python
from rubkey import Rubkey, Button, InlineKeypad
from rubkey.enums import ButtonType

bot = Rubkey("YOUR_BOT_TOKEN")

button = Button("num_btn", "Select Quantity", ButtonType.NUMBER_PICKER)
button.set_number_picker(
    title="Choose quantity",
    min_value=1,
    max_value=100,
    default_value=10
)

keypad = InlineKeypad().add_row(button)
bot.send_message("chat_id", "How many items?", inline_keypad=keypad)
```

Button with textbox

```python
from rubkey import Rubkey, Button, InlineKeypad
from rubkey.enums import ButtonType, TextboxLineType, TextboxKeypadType

bot = Rubkey("YOUR_BOT_TOKEN")

button = Button("text_btn", "Write Message", ButtonType.TEXTBOX)
button.set_textbox(
    title="Enter your message",
    place_holder="Type here...",
    default_value="Hello",
    type_line=TextboxLineType.MULTI_LINE,
    type_keypad=TextboxKeypadType.STRING
)

keypad = InlineKeypad().add_row(button)
bot.send_message("chat_id", "Please write your message:", inline_keypad=keypad)
```

Button with location picker

```python
from rubkey import Rubkey, Button, InlineKeypad, Location
from rubkey.enums import ButtonType, LocationType

bot = Rubkey("YOUR_BOT_TOKEN")

default_location = Location({"latitude": "35.6892", "longitude": "51.3890"})

button = Button("loc_btn", "Select Location", ButtonType.LOCATION)
button.set_location(
    title="Pick a location",
    default_pointer_location=default_location,
    default_map_location=default_location,
    location_type=LocationType.PICKER
)

keypad = InlineKeypad().add_row(button)
bot.send_message("chat_id", "Please select your location:", inline_keypad=keypad)
```

Chat keypad (keyboard at bottom)

```python
from rubkey import Rubkey, Button, ChatKeypad
from rubkey.enums import ButtonType

bot = Rubkey("YOUR_BOT_TOKEN")

button1 = Button("btn1", "Option A", ButtonType.SIMPLE)
button2 = Button("btn2", "Option B", ButtonType.SIMPLE)
button3 = Button("btn3", "Option C", ButtonType.SIMPLE)

keypad = ChatKeypad(resize_keyboard=True, one_time_keyboard=False)
keypad.add_row(button1, button2).add_row(button3)

bot.send_message("chat_id", "Choose an option:", chat_keypad=keypad, chat_keypad_type="New")
```

Remove chat keypad

```python
from rubkey import Rubkey

bot = Rubkey("YOUR_BOT_TOKEN")
bot.remove_chat_keypad("chat_id")
```

API Reference

Rubkey Class

Method Description
get_me() Get bot information
get_updates(limit=10) Get new updates
poll_updates(limit=10, sleep=1) Generator for continuous polling
send_message() Send text message with optional keypad and metadata
send_poll() Send poll
send_location() Send location
send_contact() Send contact
send_file() Send file
request_send_file(file_type) Get upload URL for file
upload_file(upload_url, file_path) Upload file to server
get_file(file_id) Get file download URL
get_chat(chat_id) Get chat information
delete_message(chat_id, message_id) Delete message
edit_message_text(chat_id, message_id, text) Edit message text
edit_message_keypad(chat_id, message_id, inline_keypad) Edit message keypad
forward_message(from_chat_id, to_chat_id, message_id) Forward message
ban_chat_member(chat_id, user_id) Ban user from group
unban_chat_member(chat_id, user_id) Unban user from group
set_commands(commands) Set bot commands
edit_chat_keypad(chat_id, chat_keypad, chat_keypad_type) Edit chat keypad
remove_chat_keypad(chat_id) Remove chat keypad
update_bot_endpoints(url, endpoint_type) Update webhook endpoints

License

MIT License (c) 2026 taha ansarianpour
