add comments
This commit is contained in:
+11
-12
@@ -33,6 +33,7 @@ zen_rows = ['Beautiful is better than ugly.', 'Explicit is better than implicit.
|
|||||||
|
|
||||||
|
|
||||||
def wait_for_readers(action, chat_id, msg_id):
|
def wait_for_readers(action, chat_id, msg_id):
|
||||||
|
""" Show message "User banned" until limited time, then delete. """
|
||||||
sleep(60)
|
sleep(60)
|
||||||
action(chat_id, msg_id)
|
action(chat_id, msg_id)
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ def wait_for_readers(action, chat_id, msg_id):
|
|||||||
message.text.startswith('🍀GREEN ROOM🍀')),
|
message.text.startswith('🍀GREEN ROOM🍀')),
|
||||||
content_types=['animation', 'text'])
|
content_types=['animation', 'text'])
|
||||||
def moderate_messages(message: types.Message):
|
def moderate_messages(message: types.Message):
|
||||||
|
""" Ban user and delete their message. """
|
||||||
warn = bot.send_message(message.chat.id,
|
warn = bot.send_message(message.chat.id,
|
||||||
f'♻ <b><a href="tg://user?id={message.from_user.id}">{message.from_user.first_name}</a></b>'
|
f'♻ <b><a href="tg://user?id={message.from_user.id}">{message.from_user.first_name}</a></b>'
|
||||||
f' заблокирован.', parse_mode='HTML')
|
f' заблокирован.', parse_mode='HTML')
|
||||||
@@ -53,6 +55,7 @@ def moderate_messages(message: types.Message):
|
|||||||
|
|
||||||
@bot.message_handler(commands=['rules'])
|
@bot.message_handler(commands=['rules'])
|
||||||
def send_lutz_command(message):
|
def send_lutz_command(message):
|
||||||
|
""" Send link to the Chat Rules. """
|
||||||
bot.send_message(message.chat.id,
|
bot.send_message(message.chat.id,
|
||||||
'<b>🟡 <u><a href="https://telegra.ph/pythonchatru-07-07">Правила чата</a></u></b>',
|
'<b>🟡 <u><a href="https://telegra.ph/pythonchatru-07-07">Правила чата</a></u></b>',
|
||||||
parse_mode='HTML',
|
parse_mode='HTML',
|
||||||
@@ -63,6 +66,7 @@ def send_lutz_command(message):
|
|||||||
|
|
||||||
@bot.message_handler(commands=['faq'])
|
@bot.message_handler(commands=['faq'])
|
||||||
def send_lutz_command(message):
|
def send_lutz_command(message):
|
||||||
|
""" Send link to the Chat FAQ. """
|
||||||
bot.send_message(message.chat.id,
|
bot.send_message(message.chat.id,
|
||||||
'<b>🔵 <u><a href="https://telegra.ph/faq-10-07-4">FAQ</a></u></b>',
|
'<b>🔵 <u><a href="https://telegra.ph/faq-10-07-4">FAQ</a></u></b>',
|
||||||
parse_mode='HTML',
|
parse_mode='HTML',
|
||||||
@@ -73,6 +77,7 @@ def send_lutz_command(message):
|
|||||||
|
|
||||||
@bot.message_handler(commands=['lutz'])
|
@bot.message_handler(commands=['lutz'])
|
||||||
def send_lutz_command(message):
|
def send_lutz_command(message):
|
||||||
|
""" Send the Lutz's Book. """
|
||||||
bot.send_document(
|
bot.send_document(
|
||||||
message.chat.id,
|
message.chat.id,
|
||||||
document='BQACAgQAAxkBAAPBYsWJG9Ml0fPrnbU9UyzTQiQSuHkAAjkDAAIstCxSkuRbXAlcqeQpBA',
|
document='BQACAgQAAxkBAAPBYsWJG9Ml0fPrnbU9UyzTQiQSuHkAAjkDAAIstCxSkuRbXAlcqeQpBA',
|
||||||
@@ -85,6 +90,7 @@ def send_lutz_command(message):
|
|||||||
|
|
||||||
@bot.message_handler(commands=['lib', 'library', 'book', 'books'])
|
@bot.message_handler(commands=['lib', 'library', 'book', 'books'])
|
||||||
def send_lutz_command(message):
|
def send_lutz_command(message):
|
||||||
|
""" Send link to the Chat's Library. """
|
||||||
bot.send_message(message.chat.id,
|
bot.send_message(message.chat.id,
|
||||||
'📚 <b><u><a href="https://telegra.ph/what-to-read-10-06">Библиотека питониста</a></u></b>',
|
'📚 <b><u><a href="https://telegra.ph/what-to-read-10-06">Библиотека питониста</a></u></b>',
|
||||||
parse_mode='HTML',
|
parse_mode='HTML',
|
||||||
@@ -93,16 +99,9 @@ def send_lutz_command(message):
|
|||||||
logging(message)
|
logging(message)
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['start'])
|
|
||||||
def send_start_notify_admin(message):
|
|
||||||
bot.send_message(
|
|
||||||
ADMIN_ID, get_me(message), parse_mode='HTML')
|
|
||||||
logging(message)
|
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['log'])
|
@bot.message_handler(commands=['log'])
|
||||||
def send_log(message):
|
def send_log(message):
|
||||||
"""Send log from log.csv"""
|
""" Send the last log rows. """
|
||||||
if message.from_user.id == ADMIN_ID:
|
if message.from_user.id == ADMIN_ID:
|
||||||
file_path = f"logs/log_{dt.now().strftime('%Y-%m')}.csv"
|
file_path = f"logs/log_{dt.now().strftime('%Y-%m')}.csv"
|
||||||
if exists(file_path):
|
if exists(file_path):
|
||||||
@@ -116,7 +115,7 @@ def send_log(message):
|
|||||||
|
|
||||||
@bot.inline_handler(lambda query: True)
|
@bot.inline_handler(lambda query: True)
|
||||||
def default_query(inline_query):
|
def default_query(inline_query):
|
||||||
"""Inline Texts"""
|
""" Inline the Zen of Python. """
|
||||||
zen = []
|
zen = []
|
||||||
for id_p, phrase in enumerate(zen_rows):
|
for id_p, phrase in enumerate(zen_rows):
|
||||||
q = inline_query.query.casefold()
|
q = inline_query.query.casefold()
|
||||||
@@ -130,14 +129,14 @@ def default_query(inline_query):
|
|||||||
|
|
||||||
@bot.message_handler(commands=['me'])
|
@bot.message_handler(commands=['me'])
|
||||||
def command_me(message):
|
def command_me(message):
|
||||||
"""GetMe Informer"""
|
""" Send info about user and chat id [Service]. """
|
||||||
bot.send_message(message.chat.id, get_me(message), parse_mode='HTML')
|
bot.send_message(message.chat.id, get_me(message), parse_mode='HTML')
|
||||||
logging(message)
|
logging(message)
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['remind'])
|
@bot.message_handler(commands=['remind'])
|
||||||
def remind_manually(message):
|
def remind_manually(message):
|
||||||
"""Remind manually"""
|
""" Remind holidays manually. """
|
||||||
args = message.text.split()
|
args = message.text.split()
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
try:
|
try:
|
||||||
@@ -155,7 +154,7 @@ def remind_manually(message):
|
|||||||
|
|
||||||
@bot.message_handler(commands=['jobs'])
|
@bot.message_handler(commands=['jobs'])
|
||||||
def list_jobs(message):
|
def list_jobs(message):
|
||||||
"""List all jobs"""
|
""" List all the jobs in schedule. """
|
||||||
if message.chat.id == ADMIN_ID:
|
if message.chat.id == ADMIN_ID:
|
||||||
text = reminder.print_get_jobs()
|
text = reminder.print_get_jobs()
|
||||||
bot.send_message(message.chat.id, text, parse_mode='HTML')
|
bot.send_message(message.chat.id, text, parse_mode='HTML')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
""" Helper functions for bot.py """
|
""" Send User's info. """
|
||||||
|
|
||||||
|
|
||||||
def get_me(message):
|
def get_me(message):
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
""" Logging in file. """
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
""" Schedule holidays. """
|
||||||
|
|
||||||
from schedule import repeat, every, get_jobs, run_pending
|
from schedule import repeat, every, get_jobs, run_pending
|
||||||
import time
|
import time
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|||||||
Reference in New Issue
Block a user