2022-12-05 17:22:23 +10:00
|
|
|
|
from aiogram import types, Dispatcher
|
2022-12-05 19:25:06 +10:00
|
|
|
|
from sqlalchemy.orm.session import close_all_sessions
|
2022-12-05 17:22:23 +10:00
|
|
|
|
from create_bot import bot, dp
|
|
|
|
|
from sqdb import user, session
|
2022-12-15 22:30:53 +10:00
|
|
|
|
import random
|
2022-12-05 17:22:23 +10:00
|
|
|
|
from random import randint
|
|
|
|
|
import datetime
|
2022-12-16 22:16:21 +10:00
|
|
|
|
from dicktxt import ForReadDict
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["dick"])
|
|
|
|
|
async def up_dick(message: types.Message):
|
|
|
|
|
# рандомайзер
|
2022-12-07 21:12:21 +10:00
|
|
|
|
numb = randint(-6,10)
|
2022-12-05 17:22:23 +10:00
|
|
|
|
global size_change, dick_plus, dick_minus
|
2022-12-15 22:51:18 +10:00
|
|
|
|
dick_plus = ('<b>вырос</b>', '<b>подрос</b>', '<b>привстал</b>')
|
2022-12-16 22:46:34 +10:00
|
|
|
|
dick_minus = ('<b>уменьшился</b>', '<b>откусила злая гадюка</b>', '<b>продали евреи, он стал дешевле</b>')
|
2022-12-05 17:22:23 +10:00
|
|
|
|
if numb > 0:
|
2022-12-15 22:30:53 +10:00
|
|
|
|
size_change = random.choice(dick_plus) + '🚀'
|
2022-12-23 16:54:17 +10:00
|
|
|
|
#if numb = 0 size_change = random.choice(const) TODO
|
2022-12-15 22:51:18 +10:00
|
|
|
|
else: size_change = random.choice(dick_minus) + '✂'
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# работа с таблицей
|
2022-12-07 21:12:21 +10:00
|
|
|
|
try:
|
|
|
|
|
b = session.query(user).filter(user.user_id == message.from_user.id).first()
|
|
|
|
|
if b:
|
|
|
|
|
last_time = b.datetimes
|
|
|
|
|
now_time = datetime.datetime.now()
|
|
|
|
|
diff = now_time.day - last_time.day
|
2022-12-06 22:19:47 +10:00
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
if abs(diff) <= 0:
|
|
|
|
|
try:
|
|
|
|
|
current_dick = b.dick_size
|
2022-12-16 22:16:21 +10:00
|
|
|
|
|
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер <b>{current_dick}</b> см! ')
|
|
|
|
|
except:
|
|
|
|
|
print('ошибка в if diff <=0')
|
|
|
|
|
session.rollback()
|
|
|
|
|
finally:
|
|
|
|
|
session.close_all()
|
2022-12-15 22:30:53 +10:00
|
|
|
|
print('пользователь уже крутил')
|
2022-12-07 21:12:21 +10:00
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
a = session.query(user).filter(user.user_id == message.from_user.id).first() # запрос на поиск в таблице
|
|
|
|
|
updetedDick = a.dick_size = (a.dick_size + numb)
|
|
|
|
|
a.datetimes = datetime.datetime.now()
|
|
|
|
|
session.flush()
|
|
|
|
|
session.commit() #обновляет запись
|
2022-12-16 22:16:21 +10:00
|
|
|
|
randomword = ForReadDict.RandomDick()
|
2022-12-06 17:05:09 +10:00
|
|
|
|
|
2022-12-16 22:46:34 +10:00
|
|
|
|
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш <em>{randomword}</em> {size_change}\
|
2022-12-15 22:30:53 +10:00
|
|
|
|
на <b>{abs(numb)}</b> см!\n\
|
2022-12-08 21:46:03 +10:00
|
|
|
|
Теперь он равен <b>{updetedDick}</b> см! ')
|
2022-12-07 21:12:21 +10:00
|
|
|
|
except:
|
|
|
|
|
session.rollback()
|
|
|
|
|
print('ошибка в обновлении пиписы')
|
|
|
|
|
finally:
|
|
|
|
|
session.close_all()
|
|
|
|
|
print('пиписа обновлена')
|
|
|
|
|
|
|
|
|
|
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
else:
|
|
|
|
|
session.close()
|
|
|
|
|
try:
|
|
|
|
|
int_table = user(user_id = message.from_user.id, user_fullname = message.from_user.full_name, dick_size = numb, datetimes = datetime.datetime.now(),\
|
|
|
|
|
chat_id = message.chat.id)
|
|
|
|
|
|
|
|
|
|
session.add(int_table)
|
|
|
|
|
session.flush()
|
|
|
|
|
session.commit()
|
|
|
|
|
session.close()
|
|
|
|
|
|
|
|
|
|
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
|
2022-12-15 22:30:53 +10:00
|
|
|
|
на <b>{abs(numb)}</b> см!\n\
|
2022-12-08 21:46:03 +10:00
|
|
|
|
Теперь он равен <b>{numb}</b> см!')
|
2022-12-07 21:12:21 +10:00
|
|
|
|
except:
|
|
|
|
|
print('ошибка в добавлении нового пользователя')
|
|
|
|
|
session.rollback()
|
|
|
|
|
finally:
|
|
|
|
|
session.close_all()
|
|
|
|
|
print('Успешно добавлен пользователь')
|
2022-12-06 22:27:12 +10:00
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
except:
|
|
|
|
|
session.rollback()
|
|
|
|
|
print('ошибка в основном коде')
|
|
|
|
|
finally:
|
|
|
|
|
session.close_all()
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["topdick"])
|
|
|
|
|
async def send_topchat(message: types.Message):
|
2022-12-07 21:12:21 +10:00
|
|
|
|
try:
|
|
|
|
|
changechat_id = session.query(user).filter(user.user_id == message.from_user.id).first()
|
|
|
|
|
chats = message.chat.id
|
|
|
|
|
if changechat_id.chat_id != chats:
|
|
|
|
|
changechat_id.chat_id = chats
|
|
|
|
|
session.commit()
|
|
|
|
|
session.close()
|
|
|
|
|
else:
|
|
|
|
|
session.close()
|
|
|
|
|
top = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).filter(user.chat_id == chats).limit(10).all()
|
|
|
|
|
delimiter = ': '
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
# проверка на длину списка, если меньше limit, то:
|
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
sizelen = len(top)
|
|
|
|
|
if sizelen < 10:
|
|
|
|
|
lenminus = 10 - sizelen
|
|
|
|
|
top.extend(('-'*lenminus))
|
|
|
|
|
await bot.send_message(message.chat.id, f'🏆Топ 10 бубылд чата🏆\n\n\
|
|
|
|
|
🚀 {delimiter.join(map(str, top[0]))}\n\
|
|
|
|
|
💫 {delimiter.join(map(str, top[1]))}\n\
|
|
|
|
|
🍆 {delimiter.join(map(str, top[2]))}\n\
|
|
|
|
|
🍌 {delimiter.join(map(str, top[3]))}\n\
|
|
|
|
|
🐍 {delimiter.join(map(str, top[4]))}\n\
|
|
|
|
|
🐎 {delimiter.join(map(str, top[5]))}\n\
|
|
|
|
|
🌭 {delimiter.join(map(str, top[6]))}\n\
|
|
|
|
|
🌶 {delimiter.join(map(str, top[7]))}\n\
|
|
|
|
|
👌 {delimiter.join(map(str, top[8]))}\n\
|
|
|
|
|
💩 {delimiter.join(map(str, top[9]))}\n')
|
|
|
|
|
session.close()
|
|
|
|
|
# если все нормально и участников минимум 10
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
await bot.send_message(message.chat.id, f'🏆Топ 10 бубылд чата🏆\n\n\
|
|
|
|
|
🚀 {delimiter.join(map(str, top[0]))}\n\
|
|
|
|
|
💫 {delimiter.join(map(str, top[1]))}\n\
|
|
|
|
|
🍆 {delimiter.join(map(str, top[2]))}\n\
|
|
|
|
|
🍌 {delimiter.join(map(str, top[3]))}\n\
|
|
|
|
|
🐍 {delimiter.join(map(str, top[4]))}\n\
|
|
|
|
|
🐎 {delimiter.join(map(str, top[5]))}\n\
|
|
|
|
|
🌭 {delimiter.join(map(str, top[6]))}\n\
|
|
|
|
|
🌶 {delimiter.join(map(str, top[7]))}\n\
|
|
|
|
|
👌 {delimiter.join(map(str, top[8]))}\n\
|
|
|
|
|
💩 {delimiter.join(map(str, top[9]))}\n')
|
|
|
|
|
except:
|
|
|
|
|
session.rollback()
|
|
|
|
|
print('ошибка в /topdick')
|
|
|
|
|
finally:
|
|
|
|
|
session.close_all()
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["globaldick"])
|
|
|
|
|
async def send_global_top(message: types.Message):
|
2022-12-07 21:12:21 +10:00
|
|
|
|
try:
|
|
|
|
|
top_chat = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).limit(10).all()
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
delimiter = ': '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await bot.send_message(message.chat.id, f'🏆Топ 10 пипис в мире🏆\n\n\
|
|
|
|
|
1. {delimiter.join(map(str, top_chat[0]))}\n\
|
|
|
|
|
2. {delimiter.join(map(str, top_chat[1]))}\n\
|
|
|
|
|
3. {delimiter.join(map(str, top_chat[2]))}\n\
|
|
|
|
|
4. {delimiter.join(map(str, top_chat[3]))}\n\
|
|
|
|
|
5. {delimiter.join(map(str, top_chat[4]))}\n\
|
|
|
|
|
6. {delimiter.join(map(str, top_chat[5]))}\n\
|
|
|
|
|
7. {delimiter.join(map(str, top_chat[6]))}\n\
|
|
|
|
|
8. {delimiter.join(map(str, top_chat[7]))}\n\
|
|
|
|
|
9. {delimiter.join(map(str, top_chat[8]))}\n\
|
|
|
|
|
10. {delimiter.join(map(str, top_chat[9]))}\n')
|
|
|
|
|
except:
|
|
|
|
|
session.rollback()
|
|
|
|
|
print('ошибка в /glovaldick')
|
|
|
|
|
finally:
|
|
|
|
|
session.close_all()
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
|
2022-12-13 17:51:47 +10:00
|
|
|
|
# def register_handlers_pipisa(dp: Dispatcher):
|
|
|
|
|
# dp.register_message_handler(up_dick)
|
|
|
|
|
# dp.register_message_handler(send_topchat)
|
|
|
|
|
# dp.register_message_handler(send_global_top)
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|