replace trolling.py to bot.py
This commit is contained in:
+32
-4
@@ -3,9 +3,9 @@ from datetime import datetime as dt
|
|||||||
from flask import Flask, request, abort
|
from flask import Flask, request, abort
|
||||||
from telebot import types
|
from telebot import types
|
||||||
import logging
|
import logging
|
||||||
|
from urllib import parse
|
||||||
|
|
||||||
from . import reminder
|
from . import reminder
|
||||||
from . import trolling
|
|
||||||
from . import admin
|
from . import admin
|
||||||
from . import report
|
from . import report
|
||||||
from .config import bot, URL_RX, ALLOWED_WORDS, ADMIN_ID, TOKEN, PYTHONCHATRU, WHITEUN, WHITEIDS
|
from .config import bot, URL_RX, ALLOWED_WORDS, ADMIN_ID, TOKEN, PYTHONCHATRU, WHITEUN, WHITEIDS
|
||||||
@@ -31,9 +31,6 @@ zen_rows = ['Beautiful is better than ugly.', 'Explicit is better than implicit.
|
|||||||
'If the implementation is easy to explain, it may be a good idea.',
|
'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!"]
|
"Namespaces are one honking great idea — let's do more of those!"]
|
||||||
|
|
||||||
if trolling:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def check_spam_list(type_message: types.Message) -> bool:
|
def check_spam_list(type_message: types.Message) -> bool:
|
||||||
""" Check for mentioning unwanted persons in text. """
|
""" Check for mentioning unwanted persons in text. """
|
||||||
@@ -241,6 +238,37 @@ def check_chat(message: types.Message):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['tsya'])
|
||||||
|
def send_tsya_link(message: types.Message):
|
||||||
|
""" тся/ться """
|
||||||
|
link = '<a href="https://tsya.ru/">-тся/-ться</a>'
|
||||||
|
if message.reply_to_message:
|
||||||
|
bot.reply_to(message.reply_to_message, link, parse_mode='HTML', disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['g'])
|
||||||
|
def google_it(message: types.Message):
|
||||||
|
""" Google it! """
|
||||||
|
if message.reply_to_message.text:
|
||||||
|
search = parse.quote_plus(message.reply_to_message.text)
|
||||||
|
bot.reply_to(message.reply_to_message, f"https://www.google.ru/search?q={search}", parse_mode='HTML',
|
||||||
|
disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
|
def check_unwanted_list(type_message: types.Message) -> bool:
|
||||||
|
""" Check for bloggers. """
|
||||||
|
unwanted_phrases = ['дудар', 'хауди', 'dudar']
|
||||||
|
for phrase in unwanted_phrases:
|
||||||
|
if phrase in type_message.text.casefold():
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(func=check_unwanted_list)
|
||||||
|
def unwanted_mentions(message: types.Message):
|
||||||
|
""" Reply to unwanted mentions. """
|
||||||
|
bot.reply_to(message, f'У нас таких не любят! 🥴', parse_mode='HTML')
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(func=check_chat, content_types=['text', 'sticker', 'photo', 'animation', 'video',
|
@bot.message_handler(func=check_chat, content_types=['text', 'sticker', 'photo', 'animation', 'video',
|
||||||
'audio', 'document'])
|
'audio', 'document'])
|
||||||
def unwanted_mentions(message: types.Message):
|
def unwanted_mentions(message: types.Message):
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ PYTHONCHATRU = -1001338616632 # pythonchatru
|
|||||||
|
|
||||||
URL_RX = re.compile(r'\w+\.\w+/\w+')
|
URL_RX = re.compile(r'\w+\.\w+/\w+')
|
||||||
ALLOWED_WORDS = ['pastebin', 'github', 'google', 'nometa', 'python', 'django', 'flask', 'fastapi',
|
ALLOWED_WORDS = ['pastebin', 'github', 'google', 'nometa', 'python', 'django', 'flask', 'fastapi',
|
||||||
'stackoverflow', 'habr', 'medium', 'youtube', 'stepik', 'telegraph']
|
'stackoverflow', 'habr', 'medium', 'youtube', 'stepik', 'telegraph', '#rtfm']
|
||||||
|
|
||||||
WHITEUN = set(os.environ.get('whitelist', '<<<ERR_USRS').split(','))
|
WHITEUN = set(os.environ.get('whitelist', '<<<ERR_USRS').split(','))
|
||||||
logging.warning(f'White users {WHITEUN}')
|
logging.warning(f'White users {WHITEUN}')
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
from .config import bot
|
|
||||||
from telebot import types
|
|
||||||
from urllib import parse
|
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['tsya'])
|
|
||||||
def send_tsya_link(message: types.Message):
|
|
||||||
""" тся/ться """
|
|
||||||
link = '<a href="https://tsya.ru/">-тся/-ться</a>'
|
|
||||||
if message.reply_to_message:
|
|
||||||
bot.reply_to(message.reply_to_message, link, parse_mode='HTML', disable_web_page_preview=True)
|
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['g'])
|
|
||||||
def google_it(message: types.Message):
|
|
||||||
""" Google it! """
|
|
||||||
if message.reply_to_message.text:
|
|
||||||
search = parse.quote_plus(message.reply_to_message.text)
|
|
||||||
bot.reply_to(message.reply_to_message, f"https://www.google.ru/search?q={search}", parse_mode='HTML',
|
|
||||||
disable_web_page_preview=True)
|
|
||||||
|
|
||||||
|
|
||||||
def check_unwanted_list(type_message: types.Message) -> bool:
|
|
||||||
""" Check for bloggers. """
|
|
||||||
unwanted_phrases = ['дудар', 'хауди', 'dudar']
|
|
||||||
for phrase in unwanted_phrases:
|
|
||||||
if phrase in type_message.text.casefold():
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(func=check_unwanted_list)
|
|
||||||
def unwanted_mentions(message: types.Message):
|
|
||||||
""" Reply to unwanted mentions. """
|
|
||||||
bot.reply_to(message, f'У нас таких не любят! 🥴', parse_mode='HTML')
|
|
||||||
Reference in New Issue
Block a user