Compare commits

..

5 commits

Author SHA1 Message Date
синечка ♡
5462214fbb web app data callback test 2026-08-31 21:04:34 +03:00
синечка ♡
a2f2815b6a local telegram lib to remove external deps 2026-08-31 21:04:17 +03:00
синечка ♡
6625506289 better debugging 2026-08-31 21:03:56 +03:00
синечка ♡
8a8b529e12 added colorama for colorful logs 2026-08-31 21:03:09 +03:00
синечка ♡
4402c15dc0 remove modules system (legacy) 2026-08-31 21:02:51 +03:00
10 changed files with 3463 additions and 7 deletions

View file

@ -4,15 +4,10 @@ from telebot.handler_backends import ContinueHandling
from models.bot import bot, send
from models.user import validate
from models import logger
# @bot.message_handler(content_types = ['text'])
# def handleAll(message):
# logger.log('Bot', f'{message.from_user.id}: {message.text}')
# return ContinueHandling()
#! Root Handlers
from .debug import *
from .main.register_user import *
# @bot.message_handler(content_types = ['text'], func = lambda m: not validate(m))
# def cantValidateHandler(message): ...

31
bot/debug.py Normal file
View file

@ -0,0 +1,31 @@
import os
import config
from pprint import pprint
from telebot.handler_backends import ContinueHandling
from models.bot import bot, Markup, Strings, send, WebAppInfo, KeyboardButton, ReplyKeyboardMarkup, Message
from models import logger
if os.getenv('ZATUPS_DEBUG'):
@bot.message_handler(content_types=['text', 'audio', 'document', 'animation', 'game', 'photo', 'sticker', 'video', 'video_note', 'voice', 'location', 'contact', 'venue', 'dice', 'new_chat_members', 'left_chat_member', 'new_chat_title', 'new_chat_photo', 'delete_chat_photo', 'group_chat_created', 'supergroup_chat_created', 'channel_chat_created', 'migrate_to_chat_id', 'migrate_from_chat_id', 'pinned_message', 'invoice', 'successful_payment', 'connected_website', 'poll', 'passport_data', 'proximity_alert_triggered', 'video_chat_scheduled', 'video_chat_started', 'video_chat_ended', 'video_chat_participants_invited', 'web_app_data', 'message_auto_delete_timer_changed', 'forum_topic_created', 'forum_topic_closed', 'forum_topic_reopened', 'forum_topic_edited', 'general_forum_topic_hidden', 'general_forum_topic_unhidden', 'write_access_allowed', 'user_shared', 'chat_shared', 'story'])
def handleAll(message: Message):
logger.log('Input', f'[{message.from_user.id if message.from_user else "??"}]: {message.content_type}')
pprint(message.json)
return ContinueHandling()
@bot.message_handler(
content_types = ['text'],
func = lambda m: '/web_' in m.text
)
def web(message: Message):
message.text = str(message.text) #! typechecker error fix
markup = ReplyKeyboardMarkup(resize_keyboard=True)
markup.add(
Strings.back_to_home,
KeyboardButton(
text=message.text,
web_app=WebAppInfo(url=config.WEB_BASE_URL+message.text)
),
row_width=1
)
send(message, message.text, markup)

View file

View file

@ -5,6 +5,7 @@ description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"colorama>=0.4.6",
"ics>=0.7.3",
"pytelegrambotapi>=4.36.1",
"python-dotenv>=1.2.3",

11
uv.lock generated
View file

@ -151,6 +151,7 @@ name = "bot-legacy"
version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "colorama" },
{ name = "ics" },
{ name = "pytelegrambotapi" },
{ name = "python-dotenv" },
@ -160,6 +161,7 @@ dependencies = [
[package.metadata]
requires-dist = [
{ name = "colorama", specifier = ">=0.4.6" },
{ name = "ics", specifier = ">=0.7.3" },
{ name = "pytelegrambotapi", specifier = ">=4.36.1" },
{ name = "python-dotenv", specifier = ">=1.2.3" },
@ -307,6 +309,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/cc/61/d01fc49b8dea277640b55a9e15960dbca9fdc8c9fde18e572d39c59f4019/charset_normalizer-3.5.1-py3-none-any.whl", hash = "sha256:6df0ec430f9a831772c23ca5a224cba36517a58a84bb32c32bb59a9fa67c47f6", size = 68658, upload-time = "2026-08-15T08:20:43.306Z" },
]
[[package]]
name = "colorama"
version = "0.4.6"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
]
[[package]]
name = "frozenlist"
version = "1.8.0"

3397
web/common/telegram.js Normal file

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Карта</title>
<script src="https://telegram.org/js/telegram-web-app.js?59"></script>
<script src="../common/telegram.js"></script>
<link rel="stylesheet" href="./styles/main.css?v12">
</head>
<body>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../common/telegram.js"></script>
</head>
<body style="filter: invert(1)">
<h1>/web_callback_test</h1>
<textarea id="data" style="width: 100%; height: 200px"></textarea>
<button style="font-size: 20px;" onclick="sendData()">Send Data</button>
<script>
const tg = window.Telegram.WebApp
const sendData = () => {
tg.sendData(document.getElementById('data').value)
}
</script>
</body>
</html>