forked from Pavel_Durov/python_bot
145 lines
5.8 KiB
Python
145 lines
5.8 KiB
Python
from cgitb import text
|
||
import datetime
|
||
import logging
|
||
from random import randint
|
||
from sqlalchemy import create_engine, MetaData, Table, Integer, String, \
|
||
Column, DateTime, ForeignKey, Numeric
|
||
from sqlalchemy.ext.declarative import declarative_base
|
||
from sqlalchemy.orm import sessionmaker
|
||
from aiogram import Bot, Dispatcher, executor, types
|
||
from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton
|
||
from sqdb import user
|
||
|
||
|
||
|
||
|
||
API_TOKEN = '5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w'
|
||
|
||
logging.basicConfig(level=logging.DEBUG)
|
||
|
||
bot = Bot(token=API_TOKEN)
|
||
dp = Dispatcher(bot)
|
||
|
||
|
||
|
||
@dp.message_handler(commands=["time"])
|
||
async def send_time(message: types.Message):
|
||
new_year = datetime.datetime(2022, 12, 31) #дата нового года
|
||
ct = datetime.datetime.now() #датавремя
|
||
cd = datetime.datetime.now().strftime("%d/%m/%Y") #дата (д,м,г)
|
||
ct1 = ct+datetime.timedelta(hours=14) # +14 часов от сервера
|
||
ct2 = ct1.strftime('%H:%M') # форматирует датувремя просто во время(ч,м)
|
||
raznitsa = (new_year - ct).days #отнимает от нг текущее время и получаем разницу в днях
|
||
|
||
days = ['день', 'дня', 'дней']
|
||
if raznitsa % 10 == 1 and raznitsa % 100 != 11:
|
||
p = 0
|
||
elif 2 <= raznitsa % 10 <= 4 and (raznitsa % 100 < 10 or raznitsa % 100 >= 20):
|
||
p = 1
|
||
else:
|
||
p = 2
|
||
num=(str(raznitsa) + ' ' + days[p])
|
||
|
||
await message.reply(f'Сегодня {cd} \nВремя: {ct2} \nДо Нового Года осталось {num}')
|
||
|
||
#####______________________ПИПИСА БОТ БУДЕТ ЗДЕСЬ__________________________________
|
||
|
||
|
||
|
||
|
||
|
||
@dp.message_handler(commands=["dick"])
|
||
async def ident(message: types.Message):
|
||
# рандомайзер
|
||
numb = randint(-7,10)
|
||
global size_change, dick_plus, dick_minus
|
||
dick_plus = f'вырос на {numb} см!'
|
||
dick_minus = f'уменьшился на {abs(numb)} см!'
|
||
if numb > 0:
|
||
size_change = dick_plus
|
||
else: size_change = dick_minus
|
||
####
|
||
|
||
|
||
|
||
# работа с таблицей
|
||
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
|
||
Session = sessionmaker(bind=engine)
|
||
session = Session()
|
||
Base = declarative_base()
|
||
if session.query(user).filter(user.user_id == message.from_user.id).first():
|
||
b = session.query(user).filter(user.user_id == message.from_user.id).first()
|
||
now_time = datetime.datetime.now()
|
||
last_time = b.datetimes
|
||
if (now_time - last_time).days <= 0:
|
||
await bot.send_message(message.chat.id, f'@{message.from_user.username}, вы уже крутили пипису, ее размер {b.dick_size} см! ')
|
||
session.close_all()
|
||
else:
|
||
a = session.query(user).filter(user.user_id == message.from_user.id).first() # запрос на поиск в таблице
|
||
a.dick_size = (a.dick_size + numb)
|
||
a.datetimes = datetime.datetime.now()
|
||
session.commit() #обновляет запись
|
||
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\
|
||
теперь он равен {a.dick_size} см! ')
|
||
session.close_all()
|
||
|
||
else:
|
||
int_table = user(user_id = message.from_user.id, user_fullname = message.from_user.full_name, dick_size = numb, datetimes = datetime.datetime.now())
|
||
session.add(int_table)
|
||
session.commit()
|
||
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\
|
||
теперь он равен {int_table.dick_size} см!')
|
||
session.close_all()
|
||
|
||
|
||
# int_table = user(user_id = message.from_user.id, user_fullname = message.from_user.full_name, dick_size = numb) #импортирую юзер из sqdb
|
||
# session.add(int_table)
|
||
# session.commit()
|
||
#обновление
|
||
# dick_update = session.query(user).filter_by(user.user_id = message.from_user.id).update({'dick_size': user.dick_size + numb})
|
||
# session.add(dick_update)
|
||
# session.commit()
|
||
#last_size = session.query(user).filter_by(user_id = message.from_user.id).select_from(dick_size = 'dick_size: ').one()
|
||
|
||
|
||
|
||
#####______________________ПИПИСА БОТ БУДЕТ ЗДЕСЬ__________________________________
|
||
|
||
@dp.message_handler(commands=["topdick"])
|
||
async def send_time(message: types.Message):
|
||
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
|
||
Session = sessionmaker(bind=engine)
|
||
session = Session()
|
||
Base = declarative_base()
|
||
for user_fullname, dick_size in session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).limit(10).all():
|
||
vocab = dict({'1': user_fullname, '-': dick_size})
|
||
await bot.send_message(message.chat.id, f'{vocab}')
|
||
session.close_all()
|
||
|
||
|
||
@dp.message_handler(commands=['start'])
|
||
async def start_func(message: types.Message):
|
||
# user_id = message.from_user.id
|
||
# user_full_name = message.from_user.full_name
|
||
# logging.INFO(f'{user_id=} {user_full_name=}', {time.asctime()})
|
||
await message.reply('похуй')
|
||
|
||
@dp.message_handler(commands=['photo'])
|
||
async def send_image(message: types.Message):
|
||
await bot.send_photo(message.chat.id, photo='https://memepedia.ru/wp-content/uploads/2018/08/ya-pidoras.jpg', reply_to_message_id=message.message_id)
|
||
|
||
@dp.message_handler(content_types=types.ContentTypes.TEXT)
|
||
async def send_faggot(message: types.Message):
|
||
print(message.text)
|
||
if message.text == 'хто я':
|
||
await bot.send_photo(message.chat.id, photo='https://www.meme-arsenal.com/memes/ecebd2339c7eab40e09874bd86a38a09.jpg')
|
||
|
||
#хуй
|
||
|
||
if __name__ == '__main__':
|
||
executor.start_polling(dp, skip_updates=True)
|
||
|
||
|
||
|
||
|