Switch to async!

This commit is contained in:
Rykov7
2023-10-28 18:47:34 +03:00
parent 65e04a36e0
commit 5d179b0de2
7 changed files with 136 additions and 233 deletions
+25 -24
View File
@@ -4,7 +4,8 @@ import logging
import telebot.types
from fastapi import FastAPI
from telebot import TeleBot, logger, types
from telebot.async_telebot import AsyncTeleBot
from telebot import logger, types
from dotenv import load_dotenv
logging.basicConfig(
@@ -20,7 +21,7 @@ TOKEN = os.environ.get("LUTZPYBOT")
if not TOKEN:
raise LookupError("LUTZPYBOT (token) has not been found in .env")
bot = TeleBot(
bot = AsyncTeleBot(
TOKEN,
"HTML",
disable_web_page_preview=True,
@@ -108,25 +109,25 @@ ZEN = [
"Namespaces are one honking great idea — let's do more of those!",
]
for white_id in WHITEIDS:
bot.set_my_commands(
commands=[
telebot.types.BotCommand("nobot", "/нобот Телебот не должен быть первым проектом"),
telebot.types.BotCommand("nogui", "/ногуи GUI приложение не должно быть первым проектом"),
telebot.types.BotCommand("nojob", "/ноджоб, Мы здесь не для того чтобы за тебя решать задачи"),
telebot.types.BotCommand("nometa", "/номета Не задавайте мета-вопросов"),
telebot.types.BotCommand("neprivet", "/непривет"),
telebot.types.BotCommand("quote", "/цитата Случайная цитата"),
telebot.types.BotCommand("lutz", "/лутц Прислать книгу Learning Python"),
telebot.types.BotCommand("bdmtss", "/бдмтсс Римшот"),
telebot.types.BotCommand("g", "/г Загуглить (аргументы или цитируемое)"),
telebot.types.BotCommand("rules", "/правила чата (работает с аргументом-номером пункта)"),
telebot.types.BotCommand("faq", "/чзв Частые вопросы"),
telebot.types.BotCommand("books", "/библиотека питониста"),
telebot.types.BotCommand("links", "/ссылки на правила, чзв и библиотеку"),
telebot.types.BotCommand("tsya", "/тся и /ться"),
telebot.types.BotCommand("add", "добавить цитату [Whitelist]"),
telebot.types.BotCommand("remove", "удалить цитату [Whitelist]"),
],
scope=telebot.types.BotCommandScopeChatMember(PYTHONCHATRU, white_id)
)
# for white_id in WHITEIDS:
# bot.set_my_commands(
# commands=[
# telebot.types.BotCommand("nobot", "/нобот Телебот не должен быть первым проектом"),
# telebot.types.BotCommand("nogui", "/ногуи GUI приложение не должно быть первым проектом"),
# telebot.types.BotCommand("nojob", "/ноджоб, Мы здесь не для того чтобы за тебя решать задачи"),
# telebot.types.BotCommand("nometa", "/номета Не задавайте мета-вопросов"),
# telebot.types.BotCommand("neprivet", "/непривет"),
# telebot.types.BotCommand("quote", "/цитата Случайная цитата"),
# telebot.types.BotCommand("lutz", "/лутц Прислать книгу Learning Python"),
# telebot.types.BotCommand("bdmtss", "/бдмтсс Римшот"),
# telebot.types.BotCommand("g", "/г Загуглить (аргументы или цитируемое)"),
# telebot.types.BotCommand("rules", "/правила чата (работает с аргументом-номером пункта)"),
# telebot.types.BotCommand("faq", "/чзв Частые вопросы"),
# telebot.types.BotCommand("books", "/библиотека питониста"),
# telebot.types.BotCommand("links", "/ссылки на правила, чзв и библиотеку"),
# telebot.types.BotCommand("tsya", "/тся и /ться"),
# telebot.types.BotCommand("add", "добавить цитату [Whitelist]"),
# telebot.types.BotCommand("remove", "удалить цитату [Whitelist]"),
# ],
# scope=telebot.types.BotCommandScopeChatMember(PYTHONCHATRU, white_id)
# )