add set commands,refactor service.py

This commit is contained in:
Rykov7
2023-04-12 19:11:03 +03:00
parent 19395e4e37
commit b7ed7bc45d
3 changed files with 33 additions and 7 deletions
+7 -6
View File
@@ -167,19 +167,20 @@ def get_quotes(message: types.Message):
func=is_white, commands=["get_group_info"], chat_types=["supergroup", "group"]
)
def get_group_info(message: types.Message):
if session.query(Chat.id).filter(Chat.chat_id == message.chat.id).first():
group = session.query(Chat).filter(Chat.chat_id == message.chat.id).first()
if group:
bot.send_message(
message.chat.id,
f"""Группа: {message.chat.title}
ID: {message.chat.id}
f"""Группа: {group.title}
ID группы: {group.chat_id}
Количество цитат: {len(session.query(Quote).filter(Quote.chat_id == message.chat.id).all())}
Последние добавленные: /get_quotes
Текущие настройки:
Антиспам: {session.query(Chat.antispam).filter(Chat.chat_id == message.chat.id).first()[0]}
Ежедневные отчёты: {session.query(Chat.report).filter(Chat.chat_id == message.chat.id).first()[0]}
Праздники: {session.query(Chat.reminder).filter(Chat.chat_id == message.chat.id).first()[0]}""",
Антиспам: {group.antispam}
Ежедневные отчёты: {group.report}
Праздники: {group.reminder}""",
)
else:
bot.send_message(message.chat.id, f"Группа не включена. Включить: /enable_stan")
+25
View File
@@ -1,6 +1,8 @@
import os
import re
import logging
import telebot.types
from flask import Flask
from telebot import TeleBot, logger, types
from dotenv import load_dotenv
@@ -97,3 +99,26 @@ ZEN = [
"If the implementation is easy to explain, it may be a good idea.",
"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)
)
+1 -1
View File
@@ -33,7 +33,7 @@ def update_stats(message: types.Message):
"Count": 1,
}
logging.info(
f"[{message.chat.id}] [{message.from_user.id}] {message.from_user.first_name}"
f"[{message.chat.title[:10]}] [{message.from_user.id}] {message.from_user.first_name}"
)
else:
s["Messages"][message.from_user.id]["Count"] += 1