styledbots 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- styledbots-1.0.0/LICENSE +21 -0
- styledbots-1.0.0/MANIFEST.in +9 -0
- styledbots-1.0.0/PKG-INFO +144 -0
- styledbots-1.0.0/README.md +115 -0
- styledbots-1.0.0/examples/basic_bot.py +48 -0
- styledbots-1.0.0/examples/full_featured_bot.py +87 -0
- styledbots-1.0.0/examples/styled_bot.py +79 -0
- styledbots-1.0.0/pyproject.toml +42 -0
- styledbots-1.0.0/requirements.txt +1 -0
- styledbots-1.0.0/setup.cfg +4 -0
- styledbots-1.0.0/setup.py +6 -0
- styledbots-1.0.0/styledbots/__init__.py +38 -0
- styledbots-1.0.0/styledbots/core/__init__.py +4 -0
- styledbots-1.0.0/styledbots/core/api.py +184 -0
- styledbots-1.0.0/styledbots/core/bot.py +270 -0
- styledbots-1.0.0/styledbots/core/exceptions.py +26 -0
- styledbots-1.0.0/styledbots/core/types.py +107 -0
- styledbots-1.0.0/styledbots/filters/__init__.py +1 -0
- styledbots-1.0.0/styledbots/filters/filters.py +88 -0
- styledbots-1.0.0/styledbots/handlers/__init__.py +2 -0
- styledbots-1.0.0/styledbots/keyboards/__init__.py +3 -0
- styledbots-1.0.0/styledbots/keyboards/builder.py +28 -0
- styledbots-1.0.0/styledbots/keyboards/inline.py +98 -0
- styledbots-1.0.0/styledbots/keyboards/reply.py +75 -0
- styledbots-1.0.0/styledbots/storage/__init__.py +3 -0
- styledbots-1.0.0/styledbots/storage/base.py +23 -0
- styledbots-1.0.0/styledbots/storage/file.py +46 -0
- styledbots-1.0.0/styledbots/storage/memory.py +27 -0
- styledbots-1.0.0/styledbots/styles/__init__.py +3 -0
- styledbots-1.0.0/styledbots/styles/formatter.py +40 -0
- styledbots-1.0.0/styledbots/styles/style.py +57 -0
- styledbots-1.0.0/styledbots/styles/templates.py +36 -0
- styledbots-1.0.0/styledbots/utils/__init__.py +1 -0
- styledbots-1.0.0/styledbots/utils/helpers.py +26 -0
- styledbots-1.0.0/styledbots/version.py +3 -0
- styledbots-1.0.0/styledbots.egg-info/PKG-INFO +144 -0
- styledbots-1.0.0/styledbots.egg-info/SOURCES.txt +38 -0
- styledbots-1.0.0/styledbots.egg-info/dependency_links.txt +1 -0
- styledbots-1.0.0/styledbots.egg-info/requires.txt +1 -0
- styledbots-1.0.0/styledbots.egg-info/top_level.txt +1 -0
styledbots-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 StyledBots Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: styledbots
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Modern, clean Telegram Bot library - Better than Telebot. Perfect for Pydroid 3
|
|
5
|
+
Author: StyledBots Team
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/styledbots/styledbots
|
|
8
|
+
Project-URL: Documentation, https://github.com/styledbots/styledbots#readme
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/styledbots/styledbots/issues
|
|
10
|
+
Keywords: telegram,bot,telebot,styledbots,pydroid,telegram-bot
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Communications :: Chat
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.7
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: requests>=2.28.0
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# StyledBots 🚀
|
|
31
|
+
|
|
32
|
+
**Modern, clean & powerful Telegram Bot library**
|
|
33
|
+
**Better than / equal to Telebot** • Perfect for **Pydroid 3**
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### For everyone (including Pydroid 3):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install styledbots
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
That's it!
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from styledbots import Bot, Style, InlineKeyboard
|
|
53
|
+
|
|
54
|
+
bot = Bot("YOUR_BOT_TOKEN")
|
|
55
|
+
|
|
56
|
+
@bot.command("start")
|
|
57
|
+
def start(message):
|
|
58
|
+
kb = InlineKeyboard()
|
|
59
|
+
kb.button("Click me", "btn1")
|
|
60
|
+
kb.button("Google", url="https://google.com")
|
|
61
|
+
|
|
62
|
+
text = f"Hello {Style.bold(message.from_user.first_name)}!"
|
|
63
|
+
bot.reply_to(message, text, reply_markup=kb)
|
|
64
|
+
|
|
65
|
+
@bot.callback_query_handler(func=lambda c: c.data == "btn1")
|
|
66
|
+
def button_handler(call):
|
|
67
|
+
call.answer("You clicked!", show_alert=True)
|
|
68
|
+
|
|
69
|
+
bot.infinity_polling()
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Features
|
|
75
|
+
|
|
76
|
+
- Simple & clean API (Telebot-compatible)
|
|
77
|
+
- Beautiful **Style** helpers (bold, italic, spoiler, code, etc.)
|
|
78
|
+
- Fluent **Inline & Reply Keyboards**
|
|
79
|
+
- Powerful **filters** system
|
|
80
|
+
- Middleware support
|
|
81
|
+
- Simple storage (Memory + File)
|
|
82
|
+
- Lightweight (only `requests`)
|
|
83
|
+
- Fully synchronous → works great on Android / Pydroid 3
|
|
84
|
+
- Type hints & clean structure
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Style Helpers
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from styledbots import Style
|
|
92
|
+
|
|
93
|
+
Style.bold("text")
|
|
94
|
+
Style.italic("text")
|
|
95
|
+
Style.underline("text")
|
|
96
|
+
Style.strike("text")
|
|
97
|
+
Style.code("code")
|
|
98
|
+
Style.pre("code block", "python")
|
|
99
|
+
Style.spoiler("hidden")
|
|
100
|
+
Style.link("Click", "https://...")
|
|
101
|
+
Style.mention(user_id, "Name")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Keyboards
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from styledbots import InlineKeyboard, ReplyKeyboard
|
|
110
|
+
|
|
111
|
+
# Inline
|
|
112
|
+
kb = InlineKeyboard()
|
|
113
|
+
kb.button("Yes", "yes").button("No", "no")
|
|
114
|
+
kb.row()
|
|
115
|
+
kb.button("Cancel", "cancel")
|
|
116
|
+
|
|
117
|
+
# Reply
|
|
118
|
+
rkb = ReplyKeyboard()
|
|
119
|
+
rkb.row("Option 1", "Option 2")
|
|
120
|
+
rkb.row("Back")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Why StyledBots?
|
|
126
|
+
|
|
127
|
+
| Feature | Telebot | StyledBots |
|
|
128
|
+
|----------------------|-------------|-----------------|
|
|
129
|
+
| Ease of use | Excellent | Excellent |
|
|
130
|
+
| Styling helpers | No | Yes |
|
|
131
|
+
| Fluent keyboards | Manual | Yes |
|
|
132
|
+
| Middleware | Limited | Yes |
|
|
133
|
+
| Storage helpers | No | Yes |
|
|
134
|
+
| Pydroid 3 ready | Yes | Yes |
|
|
135
|
+
| Clean structure | Medium | Excellent |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Links
|
|
140
|
+
|
|
141
|
+
- PyPI: https://pypi.org/project/styledbots/
|
|
142
|
+
- Source: https://github.com/styledbots/styledbots (create your repo)
|
|
143
|
+
|
|
144
|
+
Made with ❤️ for Pydroid 3 users and Telegram bot developers.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# StyledBots 🚀
|
|
2
|
+
|
|
3
|
+
**Modern, clean & powerful Telegram Bot library**
|
|
4
|
+
**Better than / equal to Telebot** • Perfect for **Pydroid 3**
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
### For everyone (including Pydroid 3):
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install styledbots
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
That's it!
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from styledbots import Bot, Style, InlineKeyboard
|
|
24
|
+
|
|
25
|
+
bot = Bot("YOUR_BOT_TOKEN")
|
|
26
|
+
|
|
27
|
+
@bot.command("start")
|
|
28
|
+
def start(message):
|
|
29
|
+
kb = InlineKeyboard()
|
|
30
|
+
kb.button("Click me", "btn1")
|
|
31
|
+
kb.button("Google", url="https://google.com")
|
|
32
|
+
|
|
33
|
+
text = f"Hello {Style.bold(message.from_user.first_name)}!"
|
|
34
|
+
bot.reply_to(message, text, reply_markup=kb)
|
|
35
|
+
|
|
36
|
+
@bot.callback_query_handler(func=lambda c: c.data == "btn1")
|
|
37
|
+
def button_handler(call):
|
|
38
|
+
call.answer("You clicked!", show_alert=True)
|
|
39
|
+
|
|
40
|
+
bot.infinity_polling()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- Simple & clean API (Telebot-compatible)
|
|
48
|
+
- Beautiful **Style** helpers (bold, italic, spoiler, code, etc.)
|
|
49
|
+
- Fluent **Inline & Reply Keyboards**
|
|
50
|
+
- Powerful **filters** system
|
|
51
|
+
- Middleware support
|
|
52
|
+
- Simple storage (Memory + File)
|
|
53
|
+
- Lightweight (only `requests`)
|
|
54
|
+
- Fully synchronous → works great on Android / Pydroid 3
|
|
55
|
+
- Type hints & clean structure
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Style Helpers
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from styledbots import Style
|
|
63
|
+
|
|
64
|
+
Style.bold("text")
|
|
65
|
+
Style.italic("text")
|
|
66
|
+
Style.underline("text")
|
|
67
|
+
Style.strike("text")
|
|
68
|
+
Style.code("code")
|
|
69
|
+
Style.pre("code block", "python")
|
|
70
|
+
Style.spoiler("hidden")
|
|
71
|
+
Style.link("Click", "https://...")
|
|
72
|
+
Style.mention(user_id, "Name")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Keyboards
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from styledbots import InlineKeyboard, ReplyKeyboard
|
|
81
|
+
|
|
82
|
+
# Inline
|
|
83
|
+
kb = InlineKeyboard()
|
|
84
|
+
kb.button("Yes", "yes").button("No", "no")
|
|
85
|
+
kb.row()
|
|
86
|
+
kb.button("Cancel", "cancel")
|
|
87
|
+
|
|
88
|
+
# Reply
|
|
89
|
+
rkb = ReplyKeyboard()
|
|
90
|
+
rkb.row("Option 1", "Option 2")
|
|
91
|
+
rkb.row("Back")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Why StyledBots?
|
|
97
|
+
|
|
98
|
+
| Feature | Telebot | StyledBots |
|
|
99
|
+
|----------------------|-------------|-----------------|
|
|
100
|
+
| Ease of use | Excellent | Excellent |
|
|
101
|
+
| Styling helpers | No | Yes |
|
|
102
|
+
| Fluent keyboards | Manual | Yes |
|
|
103
|
+
| Middleware | Limited | Yes |
|
|
104
|
+
| Storage helpers | No | Yes |
|
|
105
|
+
| Pydroid 3 ready | Yes | Yes |
|
|
106
|
+
| Clean structure | Medium | Excellent |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Links
|
|
111
|
+
|
|
112
|
+
- PyPI: https://pypi.org/project/styledbots/
|
|
113
|
+
- Source: https://github.com/styledbots/styledbots (create your repo)
|
|
114
|
+
|
|
115
|
+
Made with ❤️ for Pydroid 3 users and Telegram bot developers.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Basic StyledBots example
|
|
3
|
+
Works perfectly in Pydroid 3
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from styledbots import Bot, Style
|
|
7
|
+
|
|
8
|
+
# Replace with your token
|
|
9
|
+
TOKEN = "YOUR_BOT_TOKEN_HERE"
|
|
10
|
+
|
|
11
|
+
bot = Bot(TOKEN)
|
|
12
|
+
|
|
13
|
+
@bot.command("start")
|
|
14
|
+
def start(message):
|
|
15
|
+
name = message.from_user.first_name
|
|
16
|
+
text = Style.bold(f"Hello {name}!") + "\n\nWelcome to StyledBots 🚀"
|
|
17
|
+
bot.reply_to(message, text)
|
|
18
|
+
|
|
19
|
+
@bot.command("help")
|
|
20
|
+
def help_cmd(message):
|
|
21
|
+
bot.reply_to(message,
|
|
22
|
+
Style.bold("Available commands:") + "\n"
|
|
23
|
+
"/start - Start the bot\n"
|
|
24
|
+
"/help - Show this help\n"
|
|
25
|
+
"/style - See styling demo"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
@bot.command("style")
|
|
29
|
+
def style_demo(message):
|
|
30
|
+
text = (
|
|
31
|
+
f"{Style.bold('Bold text')}\n"
|
|
32
|
+
f"{Style.italic('Italic text')}\n"
|
|
33
|
+
f"{Style.underline('Underlined')}\n"
|
|
34
|
+
f"{Style.strike('Strikethrough')}\n"
|
|
35
|
+
f"{Style.code('inline code')}\n"
|
|
36
|
+
f"{Style.spoiler('Hidden spoiler')}\n"
|
|
37
|
+
f"{Style.link('Click me', 'https://t.me')}\n\n"
|
|
38
|
+
f"{Style.pre('print(\"Hello StyledBots\")', 'python')}"
|
|
39
|
+
)
|
|
40
|
+
bot.reply_to(message, text)
|
|
41
|
+
|
|
42
|
+
@bot.message_handler(func=lambda m: True)
|
|
43
|
+
def echo(message):
|
|
44
|
+
bot.reply_to(message, f"You said: {Style.code(message.text)}")
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
print("Starting basic bot...")
|
|
48
|
+
bot.infinity_polling()
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Full featured example showing almost everything
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from styledbots import Bot, Style, InlineKeyboard, filters
|
|
6
|
+
from styledbots.storage import MemoryStorage
|
|
7
|
+
from styledbots.styles.templates import Templates
|
|
8
|
+
|
|
9
|
+
TOKEN = "YOUR_BOT_TOKEN_HERE"
|
|
10
|
+
bot = Bot(TOKEN)
|
|
11
|
+
storage = MemoryStorage()
|
|
12
|
+
|
|
13
|
+
# ===== Middleware example =====
|
|
14
|
+
@bot.middleware_handler()
|
|
15
|
+
def log_updates(update):
|
|
16
|
+
if update.message:
|
|
17
|
+
user = update.message.from_user
|
|
18
|
+
print(f"[{user.id}] {user.first_name}: {update.message.text}")
|
|
19
|
+
|
|
20
|
+
# ===== Commands =====
|
|
21
|
+
@bot.command("start", "help")
|
|
22
|
+
def start(message):
|
|
23
|
+
kb = InlineKeyboard()
|
|
24
|
+
kb.button("📊 Stats", "stats")
|
|
25
|
+
kb.button("💾 Save Data", "save")
|
|
26
|
+
kb.row()
|
|
27
|
+
kb.button("✅ Yes / No Demo", "yesno")
|
|
28
|
+
|
|
29
|
+
bot.reply_to(
|
|
30
|
+
message,
|
|
31
|
+
Templates.welcome(message.from_user.first_name),
|
|
32
|
+
reply_markup=kb
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
@bot.command("stats")
|
|
36
|
+
def stats(message):
|
|
37
|
+
count = storage.get("message_count", 0)
|
|
38
|
+
bot.reply_to(message, f"Total messages processed: {Style.code(str(count))}")
|
|
39
|
+
|
|
40
|
+
# ===== Callbacks =====
|
|
41
|
+
@bot.callback_query_handler(func=lambda c: c.data == "stats")
|
|
42
|
+
def cb_stats(call):
|
|
43
|
+
count = storage.get("message_count", 0)
|
|
44
|
+
call.answer(f"Messages: {count}", show_alert=True)
|
|
45
|
+
|
|
46
|
+
@bot.callback_query_handler(func=lambda c: c.data == "save")
|
|
47
|
+
def cb_save(call):
|
|
48
|
+
storage.set(f"user_{call.from_user.id}", {
|
|
49
|
+
"name": call.from_user.first_name,
|
|
50
|
+
"username": call.from_user.username
|
|
51
|
+
})
|
|
52
|
+
call.answer("Data saved!", show_alert=True)
|
|
53
|
+
|
|
54
|
+
@bot.callback_query_handler(func=lambda c: c.data == "yesno")
|
|
55
|
+
def cb_yesno(call):
|
|
56
|
+
from styledbots.keyboards.builder import KeyboardBuilder
|
|
57
|
+
kb = KeyboardBuilder.yes_no("answer_yes", "answer_no")
|
|
58
|
+
bot.edit_message_text(
|
|
59
|
+
"Do you like StyledBots?",
|
|
60
|
+
chat_id=call.message.chat.id,
|
|
61
|
+
message_id=call.message.message_id,
|
|
62
|
+
reply_markup=kb
|
|
63
|
+
)
|
|
64
|
+
call.answer()
|
|
65
|
+
|
|
66
|
+
@bot.callback_query_handler(func=lambda c: c.data in ("answer_yes", "answer_no"))
|
|
67
|
+
def cb_answer(call):
|
|
68
|
+
if call.data == "answer_yes":
|
|
69
|
+
text = Templates.success("Awesome! Glad you like it ❤️")
|
|
70
|
+
else:
|
|
71
|
+
text = Templates.info("Feedback", "Thanks for your honesty!")
|
|
72
|
+
bot.edit_message_text(
|
|
73
|
+
text,
|
|
74
|
+
chat_id=call.message.chat.id,
|
|
75
|
+
message_id=call.message.message_id
|
|
76
|
+
)
|
|
77
|
+
call.answer()
|
|
78
|
+
|
|
79
|
+
# ===== Catch-all =====
|
|
80
|
+
@bot.message_handler(func=lambda m: True)
|
|
81
|
+
def counter(message):
|
|
82
|
+
count = storage.get("message_count", 0) + 1
|
|
83
|
+
storage.set("message_count", count)
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
print("Starting full featured bot...")
|
|
87
|
+
bot.infinity_polling()
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Full featured StyledBots example with keyboards + styles
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from styledbots import Bot, Style, InlineKeyboard, ReplyKeyboard, filters
|
|
6
|
+
from styledbots.styles.templates import Templates
|
|
7
|
+
|
|
8
|
+
TOKEN = "YOUR_BOT_TOKEN_HERE"
|
|
9
|
+
bot = Bot(TOKEN)
|
|
10
|
+
|
|
11
|
+
@bot.command("start")
|
|
12
|
+
def start(message):
|
|
13
|
+
kb = InlineKeyboard()
|
|
14
|
+
kb.button("🎨 Styles Demo", "styles")
|
|
15
|
+
kb.button("⌨️ Keyboards", "keyboards")
|
|
16
|
+
kb.row()
|
|
17
|
+
kb.button("ℹ️ About", "about")
|
|
18
|
+
kb.button("🔗 Source", url="https://github.com")
|
|
19
|
+
|
|
20
|
+
text = Templates.welcome(message.from_user.first_name)
|
|
21
|
+
bot.send_message(message.chat.id, text, reply_markup=kb)
|
|
22
|
+
|
|
23
|
+
@bot.callback_query_handler(func=lambda c: c.data == "styles")
|
|
24
|
+
def styles_callback(call):
|
|
25
|
+
text = (
|
|
26
|
+
f"{Style.bold('🎨 Style Showcase')}\n\n"
|
|
27
|
+
f"{Style.bold('Bold')} | {Style.italic('Italic')} | {Style.underline('Underline')}\n"
|
|
28
|
+
f"{Style.strike('Strike')} | {Style.code('code')} | {Style.spoiler('spoiler')}\n\n"
|
|
29
|
+
f"{Style.pre('def hello():\\n print(\"StyledBots\")', 'python')}"
|
|
30
|
+
)
|
|
31
|
+
bot.edit_message_text(
|
|
32
|
+
text,
|
|
33
|
+
chat_id=call.message.chat.id,
|
|
34
|
+
message_id=call.message.message_id
|
|
35
|
+
)
|
|
36
|
+
call.answer()
|
|
37
|
+
|
|
38
|
+
@bot.callback_query_handler(func=lambda c: c.data == "keyboards")
|
|
39
|
+
def keyboards_callback(call):
|
|
40
|
+
kb = ReplyKeyboard()
|
|
41
|
+
kb.row("Option 1", "Option 2")
|
|
42
|
+
kb.row("Option 3")
|
|
43
|
+
kb.row("🔙 Back")
|
|
44
|
+
|
|
45
|
+
bot.send_message(
|
|
46
|
+
call.message.chat.id,
|
|
47
|
+
"Here's a Reply Keyboard:",
|
|
48
|
+
reply_markup=kb
|
|
49
|
+
)
|
|
50
|
+
call.answer("Keyboard sent!")
|
|
51
|
+
|
|
52
|
+
@bot.callback_query_handler(func=lambda c: c.data == "about")
|
|
53
|
+
def about_callback(call):
|
|
54
|
+
text = (
|
|
55
|
+
f"{Style.bold('StyledBots v1.0')}\n\n"
|
|
56
|
+
f"Modern Telegram Bot library\n"
|
|
57
|
+
f"Better than Telebot • Perfect for Pydroid 3\n\n"
|
|
58
|
+
f"Features:\n"
|
|
59
|
+
f"• Beautiful styling helpers\n"
|
|
60
|
+
f"• Fluent keyboards\n"
|
|
61
|
+
f"• Clean filters\n"
|
|
62
|
+
f"• Middleware support\n"
|
|
63
|
+
f"• Lightweight (only requests)"
|
|
64
|
+
)
|
|
65
|
+
call.answer()
|
|
66
|
+
bot.send_message(call.message.chat.id, text)
|
|
67
|
+
|
|
68
|
+
@bot.message_handler(func=lambda m: m.text == "🔙 Back")
|
|
69
|
+
def back_handler(message):
|
|
70
|
+
from styledbots.keyboards.reply import ReplyKeyboardRemove
|
|
71
|
+
bot.send_message(
|
|
72
|
+
message.chat.id,
|
|
73
|
+
"Keyboard removed.",
|
|
74
|
+
reply_markup=ReplyKeyboardRemove()
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
if __name__ == "__main__":
|
|
78
|
+
print("Starting styled bot...")
|
|
79
|
+
bot.infinity_polling()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "styledbots"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Modern, clean Telegram Bot library - Better than Telebot. Perfect for Pydroid 3"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.7"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "StyledBots Team"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["telegram", "bot", "telebot", "styledbots", "pydroid", "telegram-bot"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.7",
|
|
22
|
+
"Programming Language :: Python :: 3.8",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Topic :: Communications :: Chat",
|
|
29
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"requests>=2.28.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/styledbots/styledbots"
|
|
37
|
+
Documentation = "https://github.com/styledbots/styledbots#readme"
|
|
38
|
+
"Bug Tracker" = "https://github.com/styledbots/styledbots/issues"
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.packages.find]
|
|
41
|
+
where = ["."]
|
|
42
|
+
include = ["styledbots*"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.28.0
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
StyledBots - Modern, clean & powerful Telegram Bot library
|
|
3
|
+
Better than / equal to Telebot • Perfect for Pydroid 3
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .core.bot import Bot
|
|
7
|
+
from .core.exceptions import (
|
|
8
|
+
StyledBotsError,
|
|
9
|
+
TelegramAPIError,
|
|
10
|
+
NetworkError,
|
|
11
|
+
InvalidTokenError,
|
|
12
|
+
)
|
|
13
|
+
from .core.types import Message, User, Chat, CallbackQuery, Update
|
|
14
|
+
from .styles.style import Style
|
|
15
|
+
from .keyboards.inline import InlineKeyboard
|
|
16
|
+
from .keyboards.reply import ReplyKeyboard
|
|
17
|
+
from .keyboards.builder import KeyboardBuilder
|
|
18
|
+
from .filters.filters import filters
|
|
19
|
+
from .version import __version__
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"Bot",
|
|
23
|
+
"Style",
|
|
24
|
+
"InlineKeyboard",
|
|
25
|
+
"ReplyKeyboard",
|
|
26
|
+
"KeyboardBuilder",
|
|
27
|
+
"filters",
|
|
28
|
+
"Message",
|
|
29
|
+
"User",
|
|
30
|
+
"Chat",
|
|
31
|
+
"CallbackQuery",
|
|
32
|
+
"Update",
|
|
33
|
+
"StyledBotsError",
|
|
34
|
+
"TelegramAPIError",
|
|
35
|
+
"NetworkError",
|
|
36
|
+
"InvalidTokenError",
|
|
37
|
+
"__version__",
|
|
38
|
+
]
|