This commit is contained in:
Egor Deev 2022-03-22 20:52:16 +07:00 committed by GitHub
parent 8bcb131267
commit f132905659
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 181 additions and 39 deletions

71
base.py
View file

@ -1,9 +1,14 @@
# ДАННЫЕ БОТА
TOKEN = "your bot token"
TOKEN = "1791246735:AAF3f6tb4T2Rk8atewn-2-2vQ6Q-DVy41Fc"
MY_GROUP = "-1001486717553"
# РИКРОЛЛ
RICKROLL_1 = 'https://vk.cc/8U7VuC' # https://www.youtube.com/watch?v=dQw4w9WgXcQ
RICKROLL_2 = 'https://vk.cc/3A9NI7' # https://youtu.be/dQw4w9WgXcQ
# ОБРАЩЕНИЯ К ПОЛЬЗОВАТЕЛЯМ
KILL_LIST = ["побить", "отмудохать", "избить", "отметелить"]
TMOK_LIST = ["поцеловать", "чмокнуть", "лайкнуть"]
KILL_LIST = ["побить", "отмудохать", "избить", "уебать", "отметелить"]
TMOK_LIST = ["поцеловать", "чмокнуть", "соснуть", "лайкнуть"]
QUAT_LIST = [['дай', 'дайте'], ['ахуенный', 'ахуеный', 'охуеный', 'охуенный', 'блять', 'сука'], ['совет', 'совета']]
# ФРАЗЫ ИВЕНТ ДРАКИ
@ -21,3 +26,63 @@ TRU_ = ['Й', 'Ц', 'У', 'К', 'Е', 'Н', 'Г', 'Ш', 'Щ', 'З', 'Х', 'Ъ',
'Э', 'Я', 'Ч', 'С', 'М', 'И', 'Т', 'Ь', 'Б', 'Ю', ',']
ALB = ['а', 'у', 'о', 'ы', 'и', 'э', 'я', 'ю', 'ё', 'е', 'А', 'У', 'О', 'Ы', 'И', 'Э', 'Я', 'Ю', 'Ё', 'Е']
# НА ВСЯКИЙ СЛУЧАЙ
'''
# from filters import IsAdminFilter
# activate filters
dp.filters_factory.bind(IsAdminFilter)
# await call.message.answer(str(randint(1, 10)))
# await message.answer_sticker(r'CAACAgIAAxkBAAECmDFg8_fMoE0ZFAYxOh5KRyB2Y7VGZwACfQ0AAtMv4ElQpS-ysl5_6SAE') # ФУГА ДУМАЕТ
# state = dp.current_state(chat=config.GROUP_ID, user=message.from_user.id)
# await state.set_state(User.accepted)
# ОСУЖДАЮ
for word in base.BAN_LIST:
if word in txt:
await message.delete()
await message.answer("ОСУЖДАЮ")
print(name_group, ">>>", message.text)
for word in base.BAN_NAME:
if word in txt and not "егор" in txt:
await message.delete()
await message.answer("Для обращений существует имя!")
print(name_group, ">>", message.text)
# бан на минуту
if len(original) == 2:
if "забанься" in txt:
await message.bot.restrict_chat_member(chat_id=id_group, user_id=[base.USERS[i][1] for i in base.USERS if i == no_pct.lower().split()[0]][0],
permissions=types.ChatPermissions(),
until_date=int(time()) + (31))
await message.reply(f'{message.from_user.first_name}, по вашему желанию отлетел дурачок на минуту)')
# админ бан
@dp.message_handler(is_admin=True, commands=['ban'], commands_prefix='!/')
async def ban(message: types.Message):
if not message.reply_to_message:
await message.reply("Эта команда должна быть ответом на сообщение!")
return
await message.bot.delete_message(config.GROUP_ID, message.message_id)
await message.bot.kick_chat_member(chat_id=config.GROUP_ID, user_id=message.reply_to_message.from_user.id)
await message.bot.send_photo(chat_id=config.GROUP_ID, photo="1.jpg", caption="Пользователь унижен!\nПоздравляю ;)")
# чекер данных фото
@dp.message_handler(content_types=['photo'])
async def scan_message(msg: types.Message):
document_id = msg.photo[0].file_id
file_info = await bot.get_file(document_id)
print(f'file_id: {file_info.file_id}')
print(f'file_path: {file_info.file_path}')
print(f'file_size: {file_info.file_size}')
print(f'file_unique_id: {file_info.file_unique_id}')
'''

135
bot.py
View file

@ -1,5 +1,7 @@
import logging, random, pymorphy2, requests, asyncio, emoji, base, re
import logging, random, pymorphy2, requests
import asyncio, emoji, base, re, os
from gtts import gTTS
from sql import SQLighter
from datetime import datetime
from script import cheker, translator, notice, lang_form, times, autozak, update_stat, revers
@ -123,10 +125,12 @@ async def events(call: types.CallbackQuery):
'выместить злость на кого-нибудь\n*"Число от ... до ..."* - случайное значение из '
'диапозона\n*"Подраться с ..."* - повод кого-нибудь побить\n*"Переведи (..) - ..."* '
'- перевод слова на керпичный язык\n*"Дай блять совет!"* - даёт рандомный охуенный '
'совет\n*"Переверни - ..."* - переворачивает слова в предложении',
'совет\n*"Переверни - ..."* - переворачивает слова в предложении\n*"Озвучь - ..."* '
'- озвучивает написанный текст',
parse_mode=types.ParseMode.MARKDOWN)
# ОСТАЛЬНЫЕ КОМАНДЫ
@dp.message_handler(commands=['all'], commands_prefix='@/')
async def always(message: types.Message):
update_stat(3, message, True)
@ -322,7 +326,8 @@ async def update(message: types.Message):
update_stat(3, message, True)
text_edit = re.sub(r'[^\w\s]', '', message.text.lower()).split()
if len(text_edit) == 2:
db.edit_name(message.from_user.id, text_edit[1], message.chat.id, 1)
norm = morph.parse(text_edit[1])[0].normal_form
db.edit_name(message.from_user.id, norm, message.chat.id, 1)
name_edit = db.name_lst(message.chat.id)[db.id_lst(message.chat.id).index(str(message.from_user.id))]
await message.reply(f'{name_edit.title()}, ваше имя было успешно изменено)')
else:
@ -381,6 +386,7 @@ async def closing(message: types.Message):
await message.answer("У вас уже отключены текстовые ивенты!")
# ФИКСАЦИЯ СТАТИСТИКИ СООБЩЕНИЙ
@dp.message_handler(
content_types=["migrate_to_chat_id", "migrate_from_chat_id", "new_chat_title", "new_chat_photo", "pinned_message",
"voice_chat_scheduled", "voice_chat_started", "voice_chat_ended", "voice_chat_participants_invited",
@ -477,6 +483,14 @@ async def send_events(message: types.Message):
await message.answer(revers(message.text[22:], False))
return
if len(original) > 1 and no_pct.split()[0] == 'озвучь' and "озвучь - " in txt:
text_to_voice = message.text[9:]
tts = gTTS(text_to_voice, lang='ru')
tts.save('voice.ogg')
await bot.send_voice(chat_id=message.chat.id, voice=open('voice.ogg', 'rb'),
caption=f"<b>{text_to_voice}</b>", parse_mode=types.ParseMode.HTML)
os.remove("voice.ogg")
# РАНДОМ ИВЕНТЫ
if len(original) >= 2:
if "подраться с" in txt:
@ -495,47 +509,98 @@ async def send_events(message: types.Message):
# ИВЕНТ ВЗАИМОДЕЙСТВИЯ
if len(original) >= 2:
for word in base.TMOK_LIST:
if word in txt:
lst = [original[i] for i in range(len(original)) if i != 0]
text = " ".join(lst)
if "путин" not in txt:
for word in base.TMOK_LIST:
if word in txt:
lst = [original[i] for i in range(len(original)) if i != 0]
text = " ".join(lst)
slv = morph.parse(original[0].lower())[0]
slv = morph.parse(original[0].lower())[0]
await message.bot.send_photo(chat_id=id_group,
photo=open(f"data/tmok/({random.randint(1, 4)}).jpg", 'rb'),
caption=f"{message.from_user.first_name} "
f"{slv.inflect({'past', 'sing', 'indc'}).word} {text}")
await message.bot.send_photo(chat_id=id_group,
photo=open(f"data/tmok/({random.randint(1, 4)}).jpg", 'rb'),
caption=f"{message.from_user.first_name} "
f"{slv.inflect({'past', 'sing', 'indc'}).word} {text}")
for word in base.KILL_LIST:
if word in txt:
lst = [original[i] for i in range(len(original)) if i != 0]
text = " ".join(lst)
for word in base.KILL_LIST:
if word in txt:
lst = [original[i] for i in range(len(original)) if i != 0]
text = " ".join(lst)
slv = morph.parse(original[0].lower())[0]
slv = morph.parse(original[0].lower())[0]
await message.bot.send_photo(chat_id=id_group,
photo=open(f"data/kill/({random.randint(1, 6)}).jpg", 'rb'),
caption=f"{message.from_user.first_name} "
f"{slv.inflect({'past', 'sing', 'indc'}).word} {text}")
for word_1 in base.QUAT_LIST[0]:
flag = False
for word_2 in base.QUAT_LIST[1]:
for word_3 in base.QUAT_LIST[2]:
if no_pct == " ".join([word_1, word_2, word_3]):
word = (requests.get('http://fucking-great-advice.ru/api/random').text).split('"')[5]
await message.reply(word)
flag = True
await message.bot.send_photo(chat_id=id_group,
photo=open(f"data/kill/({random.randint(1, 6)}).jpg", 'rb'),
caption=f"{message.from_user.first_name} "
f"{slv.inflect({'past', 'sing', 'indc'}).word} {text}")
for word_1 in base.QUAT_LIST[0]:
flag = False
for word_2 in base.QUAT_LIST[1]:
for word_3 in base.QUAT_LIST[2]:
if no_pct == " ".join([word_1, word_2, word_3]):
word = (requests.get('http://fucking-great-advice.ru/api/random').text).split('"')[5]
await message.reply(word)
flag = True
if flag:
break
if flag:
break
if flag:
break
if no_pct == 'совет дня':
word = (requests.get('http://fucking-great-advice.ru/api/latest').text).split('"')[5]
await message.reply(word)
# PUTIN
if len(original) >= 2:
if "поклониться путину" in txt:
await message.bot.send_photo(chat_id=id_group,
photo=open("data/putin/putin.jpg", 'rb'),
caption=f"{message.from_user.first_name}! "
f"Я рад, что ты выбрал правильную сторону)")
return
if "чмокнуть путина" in txt:
if message.from_user.first_name != "Вадим":
await message.bot.send_photo(chat_id=id_group,
photo=open(f"data/putin/chmok/({random.randint(1, 5)}).jpg", 'rb'),
caption=f"{message.from_user.first_name}, "
f"был удостоен чести чмокнуть великого!")
else:
await message.bot.send_photo(chat_id=id_group,
photo=open(f"data/putin/chmok/vadim.jpg", 'rb'),
caption=f"{message.from_user.first_name}, а ты ему сразу приглянулся)")
return
if "путин вор" in txt:
await message.bot.send_photo(chat_id=id_group,
photo=open(f"data/putin/autozak/({random.randint(1, 4)}).jpg", 'rb'),
caption=f"{message.from_user.first_name}! Ваш автозак уже в пути! "
f"Примерное время ожидания составляет "
f"{autozak(message.from_user.first_name)} Рекомендуеться "
f"подготовить паспорт и наркотики для избежания лишней работы!")
return
if "лёша выйдет погулять" in txt:
await message.bot.send_photo(chat_id=id_group,
photo=open("data/putin/lesha.jpg", 'rb'),
caption=f"{message.from_user.first_name}, нет! Он сидит дома из-за "
f"плохого поведения, приходи через {times()}")
return
# ЛИСТ КОМАНДЫ
if names:
await message.reply(notice(names, False, id_group, message.from_user.id), types.ParseMode.HTML)
return
if "крид" not in norm:
await message.reply(notice(names, False, id_group, message.from_user.id), types.ParseMode.HTML)
return
else:
if int(id_group) == int(base.MY_GROUP):
if random.randint(1, 10) == 1:
await message.reply("Заебал уже, со своим ебучим Игорем Кридом")
return
else:
await message.reply(notice(names, False, id_group, message.from_user.id), types.ParseMode.HTML)
return
# ПЕРЕВОДЧИК СЛОВ
if cheker(bk, original, id_group, user) == len(txt):
@ -547,4 +612,4 @@ async def send_events(message: types.Message):
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.create_task(time(21600)) # КАЖДЫЕ 6 ЧАСОВ ПРОВЕРКА
executor.start_polling(dp, skip_updates=True)
executor.start_polling(dp, skip_updates=True)

BIN
data/putin/autozak/(1).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
data/putin/autozak/(2).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB

BIN
data/putin/autozak/(3).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

BIN
data/putin/autozak/(4).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
data/putin/chmok/(1).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

BIN
data/putin/chmok/(2).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
data/putin/chmok/(3).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
data/putin/chmok/(4).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
data/putin/chmok/(5).jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

BIN
data/putin/chmok/vadim.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
data/putin/lesha.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
data/putin/putin.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View file

@ -0,0 +1 @@
- - Здраствуйте! Это АБ+ОБОТ, который поможет вам комфортнее провести время в чате. Бот может упомянуть человека, если его имя было упомянуто в сообщении, вызвать всех участников чата, перевести слово с транслита на русский и с русского на кирпичный, а также имеет +уйму интересных функций описаных ниже! - Приятного использования! - -

View file

@ -33,6 +33,16 @@ def times():
return f'{itg} дней)'
def autozak(name):
num = str(len(name))
if int(num[-1]) == 1:
return f'{num} минута.'
elif 1 < int(num[-1]) < 5:
return f'{num} минуты.'
else:
return f'{num} минут.'
def update_stat(var, message, main=False):
db.statistics_group(message.chat.id, var)
db.user_statistic(message.from_user.id, message.chat.id, var)
@ -167,4 +177,4 @@ def revers(message, var):
return ''.join(txt)
else:
sml = [i for i in message]
return ''.join([sml[-1 - i] for i in range(len(sml))])
return ''.join([sml[-1 - i] for i in range(len(sml))])

1
sql.py
View file

@ -6,6 +6,7 @@ class SQLighter:
"""Подключаемся к БД и сохраняем курсор соединения"""
self.connection = sqlite3.connect(database)
self.cursor = self.connection.cursor()
self.cursor.execute("PRAGMA temp_store = 2")
# СВЯЗКА ГРУППЫ
def group_exists(self, id_group):