2022-12-05 17:22:23 +10:00
|
|
|
|
from aiogram import types, Dispatcher
|
2023-07-12 21:54:24 +10:00
|
|
|
|
#from sqlalchemy.orm.session import close_all_sessions
|
2022-12-05 17:22:23 +10:00
|
|
|
|
from create_bot import bot, dp
|
2023-07-12 21:54:24 +10:00
|
|
|
|
#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
|
2023-07-16 01:50:12 +10:00
|
|
|
|
from pipisa_functions import pipisa_time
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
2023-07-12 22:00:17 +10:00
|
|
|
|
#### https://docs.python-arango.com/en/main/
|
|
|
|
|
from arango import ArangoClient
|
|
|
|
|
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["dick"])
|
|
|
|
|
async def up_dick(message: types.Message):
|
2023-07-12 21:54:24 +10:00
|
|
|
|
#global size_change, dick_plus, dick_minus
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arango_client = ArangoClient(hosts='https://arango.vdk2ch.ru')
|
|
|
|
|
pipisa_db = arango_client.db('pipisa', username='root', password='stolendick527')
|
|
|
|
|
dicks_collection = pipisa_db.collection('dicks')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# рандомайзер
|
2023-07-15 05:21:27 +10:00
|
|
|
|
numb = randint(-9,10)
|
2023-07-12 21:54:24 +10:00
|
|
|
|
dick_plus = (
|
|
|
|
|
'<b>вырос</b>',
|
|
|
|
|
'<b>подрос</b>',
|
|
|
|
|
'<b>привстал</b>',
|
|
|
|
|
'<b>увеличился</b>',
|
|
|
|
|
'<b>преисполнился</b>'
|
|
|
|
|
)
|
|
|
|
|
dick_minus = (
|
|
|
|
|
'<b>неудачно потусил на сходке</b>',
|
|
|
|
|
'<b>уменьшился</b>',
|
|
|
|
|
'<b>откусила злая гадюка</b>',
|
|
|
|
|
'<b>продали евреи, он стал дешевле</b>'
|
|
|
|
|
)
|
|
|
|
|
|
2022-12-05 17:22:23 +10:00
|
|
|
|
if numb > 0:
|
2023-07-12 21:54:24 +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
|
2023-07-12 21:54:24 +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:
|
2023-07-12 21:54:24 +10:00
|
|
|
|
#### Чекнуть есть ли юзер в базе
|
2023-07-12 21:58:19 +10:00
|
|
|
|
candidate_cursor = dicks_collection.find(
|
|
|
|
|
{
|
|
|
|
|
'user_id': message.from_user.id,
|
|
|
|
|
'chat_id': message.chat.id
|
|
|
|
|
},
|
|
|
|
|
skip=0, limit=1488)
|
2023-07-13 01:16:26 +10:00
|
|
|
|
|
2023-07-12 21:54:24 +10:00
|
|
|
|
if candidate_cursor.count() > 0:
|
|
|
|
|
## Если есть то нарастить и отправить сообщение
|
|
|
|
|
|
2023-07-12 21:58:19 +10:00
|
|
|
|
user = candidate_cursor.pop()
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
2023-07-16 01:50:12 +10:00
|
|
|
|
# last_time = datetime.datetime.strptime(user['datetimes'], '%Y-%m-%d %H:%M:%S')
|
|
|
|
|
# time_to_grow = datetime.datetime.now().replace(hour=14, minute=8, second=8, microsecond=0) #+ datetime.timedelta(days=0)
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
2023-07-16 01:50:12 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if (time_to_grow - last_time).total_seconds() > 0:
|
|
|
|
|
if pipisa_time.rolltime(check_datetime=user['datetimes']):
|
2023-07-12 22:33:36 +10:00
|
|
|
|
# пришло время крутить!!
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
|
|
|
|
updetedDick = user["dick_size"] + numb
|
2022-12-07 21:12:21 +10:00
|
|
|
|
try:
|
2023-07-12 22:40:45 +10:00
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
2023-07-12 21:54:24 +10:00
|
|
|
|
metadata = dicks_collection.insert(
|
|
|
|
|
{
|
2023-07-13 01:16:26 +10:00
|
|
|
|
'_key': user['_key'], ### этот нужен чтобы апдейт прилетал тому же юзеру
|
2023-07-13 01:00:50 +10:00
|
|
|
|
'user_id': user['user_id'],
|
|
|
|
|
'user_fullname': message.from_user.full_name,
|
2023-07-12 21:54:24 +10:00
|
|
|
|
'dick_size': updetedDick,
|
|
|
|
|
'datetimes': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
2023-07-12 22:40:45 +10:00
|
|
|
|
'attempts': user['attempts'] + 1,
|
2023-07-12 21:54:24 +10:00
|
|
|
|
'chat_id': message.chat.id
|
|
|
|
|
},
|
|
|
|
|
overwrite_mode='update'
|
|
|
|
|
)
|
|
|
|
|
print(f'Успешно апдейтнули пипису @{message.from_user.username}')
|
|
|
|
|
except Exception as e2:
|
|
|
|
|
print(f'ошибка в обновлении пиписы @{message.from_user.username}')
|
|
|
|
|
print(e2)
|
|
|
|
|
|
|
|
|
|
randomword = ForReadDict.RandomDick()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш <em>{randomword}</em> {size_change}\
|
2023-07-13 00:05:06 +10:00
|
|
|
|
на <b>{abs(numb)}</b> см!\n\
|
|
|
|
|
Теперь он равен <b>{updetedDick}</b> см! ')
|
2022-12-07 21:12:21 +10:00
|
|
|
|
else:
|
2023-07-12 21:54:24 +10:00
|
|
|
|
await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер <b>{user["dick_size"]}</b> см! ')
|
2023-07-12 22:40:45 +10:00
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
metadata = dicks_collection.insert(
|
|
|
|
|
{
|
2023-07-13 01:16:26 +10:00
|
|
|
|
'_key': user['_key'], ### этот нужен чтобы апдейт прилетал тому же юзеру
|
2023-07-13 01:00:50 +10:00
|
|
|
|
'user_id': user['user_id'] ,
|
|
|
|
|
'user_fullname': message.from_user.full_name,
|
|
|
|
|
'dick_size': user['dick_size'] ,
|
2023-07-12 22:40:45 +10:00
|
|
|
|
'datetimes': user['datetimes'] ,
|
|
|
|
|
'attempts': user['attempts'] + 1,
|
2023-07-13 00:01:25 +10:00
|
|
|
|
'chat_id': message.chat.id
|
2023-07-12 22:40:45 +10:00
|
|
|
|
},
|
|
|
|
|
overwrite_mode='update'
|
|
|
|
|
)
|
|
|
|
|
print(f'Успешно апдейтнули попытку крутить пипису @{message.from_user.username}')
|
|
|
|
|
except Exception as e2:
|
|
|
|
|
print(f'ошибка в обновлении попытки крутить пипису @{message.from_user.username}')
|
|
|
|
|
print(e2)
|
|
|
|
|
|
2023-07-12 21:54:24 +10:00
|
|
|
|
print(f'пользователь @{message.from_user.username} уже крутил')
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
## если нету, то создать
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
novenkiy = {
|
|
|
|
|
'user_id': message.from_user.id,
|
|
|
|
|
'user_fullname': message.from_user.full_name,
|
|
|
|
|
'dick_size': numb,
|
|
|
|
|
'datetimes': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
2023-07-12 22:40:45 +10:00
|
|
|
|
'attempts': 1,
|
2023-07-12 21:54:24 +10:00
|
|
|
|
'chat_id': message.chat.id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#### TODO проверить как-то по-умному что мы таки его добавили
|
2023-07-13 00:03:16 +10:00
|
|
|
|
metadata = dicks_collection.insert(novenkiy, overwrite_mode='update')
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if numb > 0:
|
|
|
|
|
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн показал головку 🚀\n\
|
2022-12-15 22:30:53 +10:00
|
|
|
|
на <b>{abs(numb)}</b> см!\n\
|
2023-07-12 21:54:24 +10:00
|
|
|
|
Теперь он равен <b>{numb}</b> см!')
|
|
|
|
|
else:
|
|
|
|
|
await bot.send_message(message.chat.id, f'@{message.from_user.username}, добро пожаловать в игру!🚀\n\
|
2023-07-12 22:07:03 +10:00
|
|
|
|
Ты стартуешь не с лучшей позиции, природа наградила тебя всего <b>{numb}</b> см 😬')
|
2022-12-07 21:12:21 +10:00
|
|
|
|
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
|
|
|
|
print(f'Успешно добавлен пользователь @{message.from_user.username}')
|
|
|
|
|
except Exception as e1:
|
|
|
|
|
print('ошибка в добавлении нового пользователя')
|
|
|
|
|
print(e1)
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
|
2023-07-12 21:54:24 +10:00
|
|
|
|
except Exception as e:
|
|
|
|
|
print('ошибка DB в /dick')
|
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
|
|
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["topdick"])
|
|
|
|
|
async def send_topchat(message: types.Message):
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arango_client = ArangoClient(hosts='https://arango.vdk2ch.ru')
|
|
|
|
|
pipisa_db = arango_client.db('pipisa', username='root', password='stolendick527')
|
|
|
|
|
dicks_collection = pipisa_db.collection('dicks')
|
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
try:
|
2023-07-12 21:54:24 +10:00
|
|
|
|
dicks = dicks_collection.find({'chat_id': message.chat.id}, skip=0, limit=1100)
|
|
|
|
|
dicks = [d for d in dicks]
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print('ошибка DB в /topdick')
|
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
|
|
top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True)
|
|
|
|
|
|
|
|
|
|
dick_limit = min(len(top_dicks), 10)
|
|
|
|
|
top_dicks = top_dicks[:dick_limit]
|
|
|
|
|
|
|
|
|
|
dickos = ''
|
|
|
|
|
emo = ['🏆','🚀','🍆','🍌','🐍','🐎','🌭','🌶','👌','💩']
|
|
|
|
|
|
|
|
|
|
if len(top_dicks) == 0:
|
|
|
|
|
await bot.send_message(message.chat.id, '🍆 Никто ничего не нарастил! 🍌')
|
|
|
|
|
else:
|
|
|
|
|
for i in range(len(top_dicks)):
|
|
|
|
|
dickos += f' {emo[i]} {i+1}. {top_dicks[i]["user_fullname"]}: {top_dicks[i]["dick_size"]}см\n'
|
|
|
|
|
i += 1
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
2023-07-12 21:54:24 +10:00
|
|
|
|
await bot.send_message(message.chat.id, '🏆Топ 10 бубылд чата🏆\n\n' + dickos)
|
|
|
|
|
|
|
|
|
|
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=["globaldick"])
|
|
|
|
|
async def send_global_top(message: types.Message):
|
2023-07-12 21:54:24 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arango_client = ArangoClient(hosts='https://arango.vdk2ch.ru')
|
|
|
|
|
pipisa_db = arango_client.db('pipisa', username='root', password='stolendick527')
|
|
|
|
|
dicks_collection = pipisa_db.collection('dicks')
|
|
|
|
|
|
2022-12-07 21:12:21 +10:00
|
|
|
|
try:
|
2023-07-12 21:54:24 +10:00
|
|
|
|
dicks = dicks_collection.all( )
|
|
|
|
|
dicks = [d for d in dicks]
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print('ошибка DB в /glovaldick')
|
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
|
|
top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True)
|
|
|
|
|
|
|
|
|
|
dick_limit = min(len(top_dicks), 10)
|
|
|
|
|
top_dicks = top_dicks[:dick_limit]
|
|
|
|
|
|
|
|
|
|
dickos = ''
|
|
|
|
|
emo = ['🏆','🚀','💫','🍆','🍌','🐍','🐎','🌭','🌶','👌']
|
|
|
|
|
|
|
|
|
|
if len(top_dicks) == 0:
|
|
|
|
|
await bot.send_message(message.chat.id, '🍆 Никто ничего не нарастил! 🍌')
|
|
|
|
|
else:
|
|
|
|
|
for i in range(len(top_dicks)):
|
|
|
|
|
dickos += f' {emo[i]} {i+1}. {top_dicks[i]["user_fullname"]}: {top_dicks[i]["dick_size"]}см\n'
|
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
|
|
await bot.send_message(message.chat.id, '🏆Топ 10 пипис в мире🏆\n\n' + dickos)
|
2022-12-05 17:22:23 +10:00
|
|
|
|
|