- Minor translation fixes
- Fix `utils.get_topic`
- Add local and proxied url to command `.debugpin`
- Rename command `.debugpin` -> `.debugger`
pull/1/head
hikariatama 2022-11-08 22:35:02 +00:00
parent c334dfb4ca
commit e6503e95a6
10 changed files with 155 additions and 109 deletions

View File

@ -1,8 +1,8 @@
import atexit
import functools
import logging
import os
import sys
import logging
def get_startup_callback() -> callable:

View File

@ -18,6 +18,7 @@ from telethon.tl.types import Message
from .. import loader, utils
from ..inline.types import InlineCall
from ..web.debugger import WebDebugger
logger = logging.getLogger(__name__)
@ -110,6 +111,8 @@ class APIRatelimiterMod(loader.Module):
" anyone.</b>"
),
"web_pin_btn": "🐞 Show Werkzeug PIN",
"proxied_url": "🌐 Proxied URL",
"local_url": "🏠 Local URL",
}
strings_ru = {
@ -154,6 +157,8 @@ class APIRatelimiterMod(loader.Module):
" никому.</b>"
),
"web_pin_btn": "🐞 Показать Werkzeug PIN",
"proxied_url": "🌐 Проксированная ссылка",
"local_url": "🏠 Локальная ссылка",
}
strings_de = {
@ -201,19 +206,21 @@ class APIRatelimiterMod(loader.Module):
" anzuzeigen. Gib ihn niemandem.</b>"
),
"web_pin_btn": "🐞 Werkzeug PIN anzeigen",
"proxied_url": "🌐 Proxied URL",
"local_url": "🏠 Lokale URL",
}
strings_tr = {
"warning": (
"<emoji document_id=5312383351217201533>⚠️</emoji>"
" <b>Dikkat!</b>\n\nHesabın ayarlarda belirtilmiş istek sınırını aştı."
" Telegram API Floodunu önlemek için tüm <b>kullanıcı botu<b> {} saniye"
" boyunca durduruldu. Daha fazla bilgi almak için ekteki dosyayı"
" inceleyebilirsiniz. /n/ Ayrıca <code>{prefix}Destek</code> grubundan"
" yardım almanız önerilmektedir. Eğer bu işlemin kasıtlı bir işlem olduğunu"
" düşünüyorsanız, kullanıcı botunuzun açılmasının bekleyin ve bu tarz bir"
" işlem gerçekleştireceğiniz sıradaki sefer"
" <code>{prefix}suspend_api_protect</code> &lt;saniye&gt; kodunu kullanın."
"<emoji document_id=5312383351217201533>⚠️</emoji> <b>Dikkat!</b>\n\nHesap"
" yapılandırmasında belirtilen sınır değerlerini aştı. Telegram API"
" sızmalarını önlemek için <b>tüm Userbot</b> {} sanie donduruldu. Daha"
" fazla bilgi için aşağıya eklenen dosyaya bakın.\n\nLütfen"
" <code>{prefix}support</code> grubu ile yardım almak için destek"
" olun!\n\nEğer bu, Userbot'un planlanmış davranışı olduğunu"
" düşünüyorsanız, zamanlayıcı bittiğinde ve"
" <code>{prefix}suspend_api_protect</code> &lt;saniye cinsinden süre&gt;"
" gibi kaynak tüketen bir işlemi planladığınızda yeniden deneyin."
),
"args_invalid": (
"<emoji document_id=5312526098750252863>🚫</emoji> <b>Geçersiz"
@ -247,6 +254,8 @@ class APIRatelimiterMod(loader.Module):
" tıklayın. Onu kimseye vermeyin.</b>"
),
"web_pin_btn": "🐞 Werkzeug PIN'ini göster",
"proxied_url": "🌐 Proxied URL",
"local_url": "🏠 Lokal URL",
}
strings_uz = {
@ -287,6 +296,8 @@ class APIRatelimiterMod(loader.Module):
" Uni hech kimga bermang.</b>"
),
"web_pin_btn": "🐞 Werkzeug PIN-ni ko'rsatish",
"proxied_url": "🌐 Proxied URL",
"local_url": "🏠 Lokal URL",
}
strings_es = {
@ -334,6 +345,8 @@ class APIRatelimiterMod(loader.Module):
" Werkzeug. No se lo des a nadie.</b>"
),
"web_pin_btn": "🐞 Mostrar el PIN de Werkzeug",
"proxied_url": "🌐 URL de proxy",
"local_url": "🏠 URL local",
}
strings_kk = {
@ -373,6 +386,8 @@ class APIRatelimiterMod(loader.Module):
" басыңыз. Оны кімсіне де бермеңіз.</b>"
),
"web_pin_btn": "🐞 Werkzeug PIN кодын көрсету",
"proxied_url": "🌐 Прокси URL",
"local_url": "🏠 Жергілікті URL",
}
_ratelimiter = []
@ -527,11 +542,11 @@ class APIRatelimiterMod(loader.Module):
)
@property
def _pin(self) -> str:
return logging.getLogger().handlers[0].web_debugger.pin
def _debugger(self) -> WebDebugger:
return logging.getLogger().handlers[0].web_debugger
async def _show_pin(self, call: InlineCall):
await call.answer(f"Werkzeug PIN: {self._pin}", show_alert=True)
await call.answer(f"Werkzeug PIN: {self._debugger.pin}", show_alert=True)
@loader.command(
ru_doc="Показать PIN Werkzeug",
@ -541,15 +556,26 @@ class APIRatelimiterMod(loader.Module):
es_doc="Mostrar herramienta PIN",
kk_doc="PIN құралын көрсету",
)
async def debugpin(self, message: Message):
async def debugger(self, message: Message):
"""Show the Werkzeug PIN"""
await self.inline.form(
message=message,
text=self.strings("web_pin"),
reply_markup={
"text": self.strings("web_pin_btn"),
"callback": self._show_pin,
},
reply_markup=[
[
{
"text": self.strings("web_pin_btn"),
"callback": self._show_pin,
}
],
[
{"text": self.strings("proxied_url"), "url": self._debugger.url},
{
"text": self.strings("local_url"),
"url": f"http://127.0.0.1:{self._debugger.port}",
},
],
],
)
async def _finish(self, call: InlineCall):

View File

@ -28,33 +28,35 @@ class HikkaConfigMod(loader.Module):
strings = {
"name": "HikkaConfig",
"choose_core": "🎚 <b>Choose a category</b>",
"configure": "🎚 <b>Choose a module to configure</b>",
"configure_lib": "🪴 <b>Choose a library to configure</b>",
"choose_core": "⚙️ <b>Choose a category</b>",
"configure": "⚙️ <b>Choose a module to configure</b>",
"configure_lib": "📦 <b>Choose a library to configure</b>",
"configuring_mod": (
"🎚 <b>Choose config option for mod</b> <code>{}</code>\n\n<b>Current"
"⚙️ <b>Choose config option for mod</b> <code>{}</code>\n\n<b>Current"
" options:</b>\n\n{}"
),
"configuring_lib": (
"🪴 <b>Choose config option for library</b> <code>{}</code>\n\n<b>Current"
"📦 <b>Choose config option for library</b> <code>{}</code>\n\n<b>Current"
" options:</b>\n\n{}"
),
"configuring_option": (
"🎚 <b>Configuring option </b><code>{}</code><b> of mod"
"⚙️ <b>Configuring option </b><code>{}</code><b> of mod"
" </b><code>{}</code>\n<i> {}</i>\n\n<b>Default: {}</b>\n\n<b>Current:"
" {}</b>\n\n{}"
),
"configuring_option_lib": (
"🪴 <b>Configuring option </b><code>{}</code><b> of library"
"📦 <b>Configuring option </b><code>{}</code><b> of library"
" </b><code>{}</code>\n<i> {}</i>\n\n<b>Default: {}</b>\n\n<b>Current:"
" {}</b>\n\n{}"
),
"option_saved": (
"🎚 <b>Option </b><code>{}</code><b> of module </b><code>{}</code><b>"
"<emoji document_id=5318933532825888187>⚙️</emoji> <b>Option"
" </b><code>{}</code><b> of module </b><code>{}</code><b>"
" saved!</b>\n<b>Current: {}</b>"
),
"option_saved_lib": (
"🪴 <b>Option </b><code>{}</code><b> of library </b><code>{}</code><b>"
"<emoji document_id=5431736674147114227>📦</emoji> <b>Option"
" </b><code>{}</code><b> of library </b><code>{}</code><b>"
" saved!</b>\n<b>Current: {}</b>"
),
"option_reset": (
@ -85,37 +87,39 @@ class HikkaConfigMod(loader.Module):
"hide_value": "🔒 Hide value",
"builtin": "🛰 Built-in",
"external": "🛸 External",
"libraries": "🪴 Libraries",
"libraries": "📦 Libraries",
}
strings_ru = {
"choose_core": "🎚 <b>Выбери категорию</b>",
"configure": "🎚 <b>Выбери модуль для настройки</b>",
"configure_lib": "🪴 <b>Выбери библиотеку для настройки</b>",
"choose_core": "⚙️ <b>Выбери категорию</b>",
"configure": "⚙️ <b>Выбери модуль для настройки</b>",
"configure_lib": "📦 <b>Выбери библиотеку для настройки</b>",
"configuring_mod": (
"🎚 <b>Выбери параметр для модуля</b> <code>{}</code>\n\n<b>Текущие"
"⚙️ <b>Выбери параметр для модуля</b> <code>{}</code>\n\n<b>Текущие"
" настройки:</b>\n\n{}"
),
"configuring_lib": (
"🪴 <b>Выбери параметр для библиотеки</b> <code>{}</code>\n\n<b>Текущие"
"📦 <b>Выбери параметр для библиотеки</b> <code>{}</code>\n\n<b>Текущие"
" настройки:</b>\n\n{}"
),
"configuring_option": (
"🎚 <b>Управление параметром </b><code>{}</code><b> модуля"
"⚙️ <b>Управление параметром </b><code>{}</code><b> модуля"
" </b><code>{}</code>\n<i> {}</i>\n\n<b>Стандартное:"
" {}</b>\n\n<b>Текущее: {}</b>\n\n{}"
),
"configuring_option_lib": (
"🪴 <b>Управление параметром </b><code>{}</code><b> библиотеки"
"📦 <b>Управление параметром </b><code>{}</code><b> библиотеки"
" </b><code>{}</code>\n<i> {}</i>\n\n<b>Стандартное:"
" {}</b>\n\n<b>Текущее: {}</b>\n\n{}"
),
"option_saved": (
"🎚 <b>Параметр </b><code>{}</code><b> модуля </b><code>{}</code><b>"
"<emoji document_id=5318933532825888187>⚙️</emoji> <b>Параметр"
" </b><code>{}</code><b> модуля </b><code>{}</code><b>"
" сохранен!</b>\n<b>Текущее: {}</b>"
),
"option_saved_lib": (
"🪴 <b>Параметр </b><code>{}</code><b> библиотеки </b><code>{}</code><b>"
"<emoji document_id=5431736674147114227>📦</emoji> <b>Параметр"
" </b><code>{}</code><b> библиотеки </b><code>{}</code><b>"
" сохранен!</b>\n<b>Текущее: {}</b>"
),
"option_reset": (
@ -149,38 +153,40 @@ class HikkaConfigMod(loader.Module):
"hide_value": "🔒 Скрыть значение",
"builtin": "🛰 Встроенные",
"external": "🛸 Внешние",
"libraries": "🪴 Библиотеки",
"libraries": "📦 Библиотеки",
}
strings_de = {
"choose_core": "🎚 <b>Wähle eine Kategorie</b>",
"configure": "🎚 <b>Modul zum Konfigurieren auswählen</b>",
"configure_lib": "🪴 <b>Wählen Sie eine zu konfigurierende Bibliothek aus</b>",
"choose_core": "⚙️ <b>Wähle eine Kategorie</b>",
"configure": "⚙️ <b>Modul zum Konfigurieren auswählen</b>",
"configure_lib": "📦 <b>Wählen Sie eine zu konfigurierende Bibliothek aus</b>",
"configuring_mod": (
"🎚 <b>Wählen Sie einen Parameter für das Modul aus</b>"
"⚙️ <b>Wählen Sie einen Parameter für das Modul aus</b>"
" <code>{}</code>\n\n<b>Aktuell Einstellungen:</b>\n\n{}"
),
"configuring_lib": (
"🪴 <b>Wählen Sie eine Option für die Bibliothek aus</b>"
"📦 <b>Wählen Sie eine Option für die Bibliothek aus</b>"
" <code>{}</code>\n\n<b>Aktuell Einstellungen:</b>\n\n{}"
),
"configuring_option": (
"🎚 <b>Option </b><code>{}</code><b> des Moduls </b><code>{}</code>"
"⚙️ <b>Option </b><code>{}</code><b> des Moduls </b><code>{}</code>"
"<b> konfigurieren</b>\n<i> {}</i>\n\n<b>Standard: {}</b>\n\n<b>"
"Aktuell: {}</b>\n\n{}"
),
"configuring_option_lib": (
"🪴 <b>Option </b><code>{}</code><b> der Bibliothek </b><code>{}</code>"
"📦 <b>Option </b><code>{}</code><b> der Bibliothek </b><code>{}</code>"
"<b> konfigurieren</b>\n<i> {}</i>\n\n<b>Standard: {}</b>\n\n<b>"
"Aktuell: {}</b>\n\n{}"
),
"option_saved": (
"🎚 <b>Option </b><code>{}</code><b> des Moduls </b><code>{}</code>"
"<b> gespeichert!</b>\n<b>Aktuell: {}</b>"
"<emoji document_id=5318933532825888187>⚙️</emoji> <b>Option"
" </b><code>{}</code><b> des Moduls </b><code>{}</code><b>"
" gespeichert!</b>\n<b>Aktuell: {}</b>"
),
"option_saved_lib": (
"🪴 <b>Option </b><code>{}</code><b> der Bibliothek </b><code>{}</code>"
"<b> gespeichert!</b>\n<b>Aktuell: {}</b>"
"<emoji document_id=5431736674147114227>📦</emoji> <b>Option"
" </b><code>{}</code><b> der Bibliothek </b><code>{}</code><b>"
" gespeichert!</b>\n<b>Aktuell: {}</b>"
),
"option_reset": (
"♻️ <b>Option </b><code>{}</code><b> des Moduls </b><code>{}</code>"
@ -213,38 +219,39 @@ class HikkaConfigMod(loader.Module):
"hide_value": "🔒 Wert verbergen",
"builtin": "🛰 Ingebaut",
"external": "🛸 Extern",
"libraries": "🪴 Bibliotheken",
"libraries": "📦 Bibliotheken",
}
strings_uz = {
"choose_core": "🎚 <b>Kurum tanlang</b>",
"configure": "🎚 <b>Sozlash uchun modulni tanlang</b>",
"configure_lib": "🪴 <b>Sozlash uchun kutubxonani tanlang</b>",
"choose_core": "⚙️ <b>Kurum tanlang</b>",
"configure": "⚙️ <b>Sozlash uchun modulni tanlang</b>",
"configure_lib": "📦 <b>Sozlash uchun kutubxonani tanlang</b>",
"configuring_mod": (
"🎚 <b>Modul uchun parametrni tanlang</b> <code>{}</code>\n\n<b>Joriy"
"⚙️ <b>Modul uchun parametrni tanlang</b> <code>{}</code>\n\n<b>Joriy"
" sozlamalar:</b>\n\n{}"
),
"configuring_lib": (
"🪴 <b>Kutubxona uchun variantni tanlang</b> <code>{}</code>\n\n<b>Hozirgi"
"📦 <b>Kutubxona uchun variantni tanlang</b> <code>{}</code>\n\n<b>Hozirgi"
" sozlamalar:</b>\n\n{}"
),
"configuring_option": (
"🎚 <b>Modul </b><code>{}</code><b> sozlamasi </b><code>{}</code><b>"
"⚙️ <b>Modul </b><code>{}</code><b> sozlamasi </b><code>{}</code><b>"
" konfiguratsiya qilinmoqda</b>\n<i> {}</i>\n\n<b>Default:"
" {}</b>\n\n<b>Hozirgi: {}</b>\n\n{}"
),
"configuring_option_lib": (
"🪴 <b>Modul </b><code>{}</code><b> kutubxonasi sozlamasi"
"📦 <b>Modul </b><code>{}</code><b> kutubxonasi sozlamasi"
" </b><code>{}</code><b> konfiguratsiya qilinmoqda</b>\n<i>"
" {}</i>\n\n<b>Default: {}</b>\n\n<b>Hozirgi: {}</b>\n\n{}"
),
"option_saved": (
"🎚 <b>Modul </b><code>{}</code><b> sozlamasi saqlandi!</b>\n<b>Hozirgi:"
" {}</b>"
"<emoji document_id=5318933532825888187>⚙️</emoji> <b>Modul"
" </b><code>{}</code><b> sozlamasi saqlandi!</b>\n<b>Hozirgi: {}</b>"
),
"option_saved_lib": (
"🪴 <b>Modul </b><code>{}</code><b> kutubxonasi sozlamasi"
" saqlandi!</b>\n<b>Hozirgi: {}</b>"
"<emoji document_id=5431736674147114227>📦</emoji> <b>Modul"
" </b><code>{}</code><b> kutubxonasi sozlamasi saqlandi!</b>\n<b>Hozirgi:"
" {}</b>"
),
"option_reset": (
"♻️ <b>Modul </b><code>{}</code><b> sozlamasi standart qiymatga"
@ -271,29 +278,30 @@ class HikkaConfigMod(loader.Module):
"hide_value": "🔒 Qiymatni yashirish",
"builtin": "🛰 Ichki",
"external": "🛸 Tashqi",
"libraries": "🪴 Kutubxona",
"libraries": "📦 Kutubxona",
"close_btn": "🔻 Yopish",
"back_btn": "👈 Orqaga",
}
strings_tr = {
"configuring_option": (
"🎚 <b>Modül </b><code>{}</code><b> seçeneği </b><code>{}</code>"
"⚙️ <b>Modül </b><code>{}</code><b> seçeneği </b><code>{}</code>"
"<b> yapılandırılıyor</b>\n<i> {}</i>\n\n<b>Varsayılan: {}</b>\n\n<b>"
"Mevcut: {}</b>\n\n{}"
),
"configuring_option_lib": (
"🪴 <b>Modül </b><code>{}</code><b> kütüphanesi seçeneği </b><code>{}</code>"
"📦 <b>Modül </b><code>{}</code><b> kütüphanesi seçeneği </b><code>{}</code>"
"<b> yapılandırılıyor</b>\n<i> {}</i>\n\n<b>Varsayılan: {}</b>\n\n<b>"
"Mevcut: {}</b>\n\n{}"
),
"option_saved": (
"🎚 <b>Modül </b><code>{}</code><b> seçeneği kaydedildi!</b>\n<b>Mevcut:"
" {}</b>"
"<emoji document_id=5318933532825888187>⚙️</emoji> <b>Modül"
" </b><code>{}</code><b> seçeneği kaydedildi!</b>\n<b>Mevcut: {}</b>"
),
"option_saved_lib": (
"🪴 <b>Modül </b><code>{}</code><b> kütüphanesi seçeneği"
" kaydedildi!</b>\n<b>Mevcut: {}</b>"
"<emoji document_id=5431736674147114227>📦</emoji> <b>Modül"
" </b><code>{}</code><b> kütüphanesi seçeneği kaydedildi!</b>\n<b>Mevcut:"
" {}</b>"
),
"option_reset": (
"♻️ <b>Modül </b><code>{}</code><b> seçeneği varsayılan değere"
@ -318,27 +326,29 @@ class HikkaConfigMod(loader.Module):
"hide_value": "🔒 Değeri gizle",
"builtin": "🛰 Dahili",
"external": "🛸 Harici",
"libraries": "🪴 Kütüphane",
"libraries": "📦 Kütüphane",
"back_btn": "👈 Geri",
}
strings_es = {
"configuring_option": (
"🎚 <b>Configurando la opción </b><code>{}</code><b> del módulo"
"⚙️ <b>Configurando la opción </b><code>{}</code><b> del módulo"
" </b><code>{}</code><b> </b>\n<i> {}</i>\n\n<b>Por defecto:"
" {}</b>\n\n<b>Actual: {}</b>\n\n{}"
),
"configuring_option_lib": (
"🪴 <b>Configurando la opción </b><code>{}</code><b> de la librería del"
"📦 <b>Configurando la opción </b><code>{}</code><b> de la librería del"
" módulo </b><code>{}</code><b> </b>\n<i> {}</i>\n\n<b>Por defecto:"
" {}</b>\n\n<b>Actual: {}</b>\n\n{}"
),
"option_saved": (
"🎚 <b>¡Guardada la opción </b><code>{}</code><b> del módulo"
" </b><code>{}</code><b>!</b>\n<b>Actual: {}</b>"
"<emoji document_id=5318933532825888187>⚙️</emoji> <b>¡Guardada la opción"
" </b><code>{}</code><b> del módulo </b><code>{}</code><b>!</b>\n<b>Actual:"
" {}</b>"
),
"option_saved_lib": (
"🪴 <b>¡Guardada la opción </b><code>{}</code><b> de la librería del módulo"
"<emoji document_id=5431736674147114227>📦</emoji> <b>¡Guardada la opción"
" </b><code>{}</code><b> de la librería del módulo"
" </b><code>{}</code><b>!</b>\n<b>Actual: {}</b>"
),
"option_reset": (
@ -365,29 +375,30 @@ class HikkaConfigMod(loader.Module):
"hide_value": "🔒 Ocultar valores",
"builtin": "🛰 Integrado",
"external": "🛸 Externo",
"libraries": "🪴 Librerías",
"libraries": "📦 Librerías",
"back_btn": "👈 Volver",
}
strings_kk = {
"configuring_option": (
"🎚 <b>Модуль </b><code>{}</code><b> ішіндегі </b><code>{}</code><b>"
"⚙️ <b>Модуль </b><code>{}</code><b> ішіндегі </b><code>{}</code><b>"
" параметрін баптау</b>\n<i> {}</i>\n\n<b>Әдепкі:"
" {}</b>\n\n<b>Ағымдағы: {}</b>\n\n{}"
),
"configuring_option_lib": (
"🪴 <b>Модуль </b><code>{}</code><b> ішіндегі"
"📦 <b>Модуль </b><code>{}</code><b> ішіндегі"
" кітапхананың</b><code>{}</code><b> параметрін баптау</b>\n<i>"
" {}</i>\n\n<b>Әдепкі: {}</b>\n\n<b>Ағымдағы: {}</b>\n\n{}"
),
"option_saved": (
"🎚 <b>Модуль </b><code>{}</code><b> ішіндегі </b><code>{}</code><b>"
" параметрі сақталды!</b>\n<b>Ағымдағы: {}</b>"
"<emoji document_id=5318933532825888187>⚙️</emoji> <b>Модуль"
" </b><code>{}</code><b> ішіндегі </b><code>{}</code><b> параметрі"
" сақталды!</b>\n<b>Ағымдағы: {}</b>"
),
"option_saved_lib": (
"🪴 <b>Модуль </b><code>{}</code><b> ішіндегі"
" кітапхананың</b><code>{}</code><b> параметрі сақталды!</b>\n<b>Ағымдағы:"
" {}</b>"
"<emoji document_id=5431736674147114227>📦</emoji> <b>Модуль"
" </b><code>{}</code><b> ішіндегі кітапхананың</b><code>{}</code><b>"
" параметрі сақталды!</b>\n<b>Ағымдағы: {}</b>"
),
"option_reset": (
"♻️ <b>Модуль </b><code>{}</code><b> ішіндегі </b><code>{}</code><b>"
@ -413,7 +424,7 @@ class HikkaConfigMod(loader.Module):
"hide_value": "🔒 Мәндерді жасыру",
"builtin": "🛰 Ішкі",
"external": "🛸 Сыртқы",
"libraries": "🪴 Кітапханалар",
"libraries": "📦 Кітапханалар",
"back_btn": "👈 Артқа",
}
@ -1381,7 +1392,7 @@ class HikkaConfigMod(loader.Module):
"""Configure modules"""
args = utils.get_args_raw(message)
if self.lookup(args) and hasattr(self.lookup(args), "config"):
form = await self.inline.form("🌘", message)
form = await self.inline.form("🌘", message, silent=True)
mod = self.lookup(args)
if isinstance(mod, loader.Library):
type_ = "library"

View File

@ -20,8 +20,8 @@ from telethon.tl.types import Message
from telethon.utils import get_display_name
from .. import loader, main, utils
from ..inline.types import InlineCall
from .._internal import restart
from ..inline.types import InlineCall
logger = logging.getLogger(__name__)

View File

@ -169,14 +169,12 @@ class PythonMod(loader.Module):
message,
self.strings("err").format(
utils.escape_html(utils.get_args_raw(message)),
utils.escape_html(
self.censor(
(
"\n".join(item.full_stack.splitlines()[:-1])
+ "\n\n"
+ "🚫 "
+ item.full_stack.splitlines()[-1]
)
self.censor(
(
"\n".join(item.full_stack.splitlines()[:-1])
+ "\n\n"
+ "🚫 "
+ item.full_stack.splitlines()[-1]
)
),
),

View File

@ -270,8 +270,8 @@ class CoreMod(loader.Module):
" document_id=5377437404078546699>💜</emoji> <b>Hikka-TL:"
" </b><i>{}</i>\n{}"
" <b>Hikka-Pyro:"
" </b><i>{}</i>\n\n<emojidocument_id=5454182070156794055>⌨️</emoji>"
" <b>Entwickler:t.me/hikariatama</b>"
" </b><i>{}</i>\n\n<emoji document_id=5454182070156794055>⌨️</emoji>"
" <b>Entwickler: t.me/hikariatama</b>"
),
"_cls_doc": "Verwaltung der Grundeinstellungen des Userbots",
"confirm_cleardb": (
@ -362,8 +362,8 @@ class CoreMod(loader.Module):
" document_id=5377437404078546699>💜</emoji> <b>Hikka-TL:"
" </b><i>{}</i>\n{}"
" <b>Hikka-Pyro:"
" </b><i>{}</i>\n\n<emojidocument_id=5454182070156794055>⌨️</emoji>"
" <b>Geliştirici:t.me/hikariatama</b>"
" </b><i>{}</i>\n\n<emoji document_id=5454182070156794055>⌨️</emoji>"
" <b>Geliştirici: t.me/hikariatama</b>"
),
"_cls_doc": "Userbot temel ayar yönetimi",
"confirm_cleardb": (
@ -624,7 +624,7 @@ class CoreMod(loader.Module):
" document_id=5377437404078546699>💜</emoji> <b>Hikka-TL:"
" </b><i>{}</i>\n{}"
" <b>Hikka-Pyro: </b><i>{}</i>\n\n<emoji"
" document_id=5454182070156794055>⌨️</emoji> <b>Developer:"
" document_id=5454182070156794055>⌨️</emoji> <b>Әзірлеуші:"
" t.me/hikariatama</b>"
),
"_cls_doc": "Жүйе бастапқы параметрлерін басқару",

View File

@ -26,8 +26,8 @@ from telethon.tl.functions.messages import (
from telethon.tl.types import DialogFilter, Message
from .. import loader, main, utils, version
from ..inline.types import InlineCall
from .._internal import get_startup_callback
from ..inline.types import InlineCall
logger = logging.getLogger(__name__)

View File

@ -25,6 +25,7 @@
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
import asyncio
import atexit as _atexit
import contextlib
import functools
import inspect
@ -35,7 +36,6 @@ import os
import random
import re
import shlex
import atexit as _atexit
import signal
import string
import time
@ -1443,7 +1443,13 @@ def get_topic(message: Message) -> typing.Optional[int]:
"""
return (
(message.reply_to.reply_to_top_id or message.reply_to.reply_to_msg_id)
if message.reply_to and message.reply_to.forum_topic
if (
isinstance(message, Message)
and message.reply_to
and message.reply_to.forum_topic
)
else message.form["top_msg_id"]
if isinstance(message, (InlineCall, InlineMessage))
else None
)

View File

@ -1,12 +1,12 @@
import asyncio
import random
from werkzeug.debug import DebuggedApplication
from werkzeug import Request, Response
from werkzeug.serving import make_server, BaseWSGIServer
import os
import random
from threading import Thread
from werkzeug import Request, Response
from werkzeug.debug import DebuggedApplication
from werkzeug.serving import BaseWSGIServer, make_server
from .. import main, utils
from . import proxypass
@ -29,7 +29,7 @@ class WebDebugger:
self.port = main.gen_port("werkzeug_port", True)
main.save_config_key("werkzeug_port", self.port)
self._url = None
self._proxypasser = proxypass.ProxyPasser()
self._proxypasser = proxypass.ProxyPasser(self._url_changed)
asyncio.ensure_future(self._getproxy())
self._create_server()
self._controller = ServerThread(self._server)
@ -39,6 +39,9 @@ class WebDebugger:
async def _getproxy(self):
self._url = await self._proxypasser.get_url(self.port)
def _url_changed(self, url: str):
self._url = url
def _create_server(self) -> BaseWSGIServer:
os.environ["WERKZEUG_DEBUG_PIN"] = self.pin
os.environ["WERKZEUG_RUN_MAIN"] = "true"

View File

@ -9,12 +9,13 @@ logger = logging.getLogger(__name__)
class ProxyPasser:
def __init__(self):
def __init__(self, change_url_callback: callable = lambda _: None):
self._tunnel_url = None
self._sproc = None
self._url_available = asyncio.Event()
self._url_available.set()
self._lock = asyncio.Lock()
self._change_url_callback = change_url_callback
async def _sleep_for_task(self, callback: callable, data: bytes, delay: int):
await asyncio.sleep(delay)
@ -57,13 +58,14 @@ class ProxyPasser:
if re.search(regex, stdout_line):
logger.debug("Proxy pass tunneled: %s", stdout_line)
self._tunnel_url = re.search(regex, stdout_line)[1]
self._change_url_callback(self._tunnel_url)
self._url_available.set()
async def get_url(self, port: int) -> typing.Optional[str]:
async with self._lock:
if self._tunnel_url:
try:
await asyncio.wait_for(self._sproc.wait(), timeout=0.1)
await asyncio.wait_for(self._sproc.wait(), timeout=0.05)
except asyncio.TimeoutError:
return self._tunnel_url
else: