space genocide
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hogweed1
2025-05-12 21:52:47 +10:00
parent 7e52c86067
commit 2830335b12
13 changed files with 88 additions and 148 deletions

View File

@@ -1,6 +1,4 @@
from handlers import pipisa
from handlers import start_help
from handlers import time_new_year

View File

@@ -3,15 +3,14 @@ import time
from prometheus_client import Gauge, Info
from global_conf import pipisa_length_metric, user_attempt_metric, user_last_attempt_metric
class user_info_struct:
user_id: str
user_fullname: str
dick_size: int
datetimes: str
attemptsCount: int
chat_id: int
class user_info_struct:
user_id: str
user_fullname: str
dick_size: int
datetimes: str
attemptsCount: int
chat_id: int
def metric_wrap(chatID:int, userName: str, length: int, attemptsCount: int):
"""Pass here chat ID, username, pipisa length and attempts count to wrap them into metric."""
@@ -26,6 +25,6 @@ def metric_wrap(chatID:int, userName: str, length: int, attemptsCount: int):
if not user_last_attempt_metric:
user_last_attempt_metric = Gauge('user_last_attempt_time', 'Last attempt time', labelnames=['ChatID', 'Username'])
pipisa_length_metric.labels(chatID, userName).set(length)
pipisa_length_metric.labels(chatID, userName).set(length)
user_attempt_metric.labels(chatID, userName).set(attemptsCount)
user_last_attempt_metric.labels(chatID, userName).set(time.time_ns())

View File

@@ -5,22 +5,16 @@ from random import randint
import datetime, logging
from dicktxt import ForReadDict, WordsChange
from pipisa_functions import pipisa_time
from global_conf import CONFIG
from db_logic import tops, user_stuff, postcleaner
admins = CONFIG['telegram_admins_ids']
@dp.message_handler(commands=["dick"])
async def up_dick(message: types.Message):
if message.from_user.id in admins or message.chat.type != 'private':
postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__DICK')
await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__DICK', max_id=message.message_id)
@@ -55,25 +49,23 @@ async def up_dick(message: types.Message):
postcleaner.append_post_to_cleaning_sequence(message=mmm, type='ALREADY_ROLLED')
await clean_posts(chat_id=mmm.chat.id, type='ALREADY_ROLLED', max_id=mmm.message_id)
else:
else:
## если нету, то создать
user_stuff.store_new_user(message, result)
await bot.send_message( message.chat.id,
f'@{message.from_user.username}, Добро пожаловать в игру! Ваш писюн показал головку 🚀\nна <b>{abs(result)}</b> см!\nТеперь он равен <b>{abs(result)}</b> см!'
)
)
else:
await message.reply('Растить елду можно только в общих чатах!')
@dp.message_handler(commands = ['topdick', 'globaldick'])
async def send_topchat(message: types.Message):
if message.from_user.id in admins or message.chat.type != 'private':
top_ = message['text'].startswith('/topdick')
glob_ = message['text'].startswith('/globaldick')
glob_ = message['text'].startswith('/globaldick')
if top_:
dickos = tops.get_tops( top_ = True, chat_id=message.chat.id )
@@ -84,21 +76,19 @@ async def send_topchat(message: types.Message):
postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__GLOBALDICK')
await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__GLOBALDICK', max_id=message.message_id)
else:
logging.error('вызывают хз что!')
logging.error('вызывают хз что!')
if not dickos:
await bot.send_message(message.chat.id, '🍆 Никто ничего не нарастил! 🍌')
else:
if top_:
await bot.send_message(message.chat.id, '🏆Топ 10 бубылд чата🏆\n\n' + dickos)
elif glob_:
elif glob_:
await bot.send_message(message.chat.id, '🏆Топ 10 пипис в мире🏆\n\n' + dickos)
else:
await message.reply('Работает только в общих чатах!\n'\
'Вы можете посмотреть топ по миру /globaldick')
@dp.message_handler(commands = ['antitopdick', 'antiglobaldick'])
async def send_antitopchat(message: types.Message):
if message.from_user.id in admins or message.chat.type != 'private':
@@ -127,10 +117,8 @@ async def send_antitopchat(message: types.Message):
await message.reply('Работает только в общих чатах!\n'\
'Вы можете посмотреть антитоп по миру /antiglobaldick')
async def clean_posts(chat_id, type=None, max_id=None):
psts = postcleaner.get_posts_to_be_removed(chat_id, type, max_id)
psts = postcleaner.get_posts_to_be_removed(chat_id, type, max_id)
for p in psts:
postcleaner.del_post(chat_id=p['chat_id'], msg_id=p['msg_id'])
@@ -138,9 +126,7 @@ async def clean_posts(chat_id, type=None, max_id=None):
#### TODO проверить админит ли бот
try:
await bot.delete_message( chat_id=p['chat_id'], message_id=p['msg_id'], )
await bot.delete_message(chat_id=p['chat_id'], message_id=p['msg_id'])
except Exception as e:
logging.error('ошибка удаления поста-на-удаление')
logging.error(e)

View File

@@ -5,23 +5,14 @@ from create_bot import dp, bot
@dp.message_handler(commands=['start'])
async def start_func(message: types.Message):
if message.chat.type == 'private':
lkb = InlineKeyboardMarkup(row_width=1).add(InlineKeyboardButton(text = 'Добавить в группу', callback_data='add_2_group'))
await message.answer(f'<b>Добро пожаловать, {message.from_user.full_name}!</b>\n'
'Это бот, который растит члены. Чтобы начать, добавь бота в чат'\
, reply_markup=lkb
)
# TODO добавить кнопку, по которой смогут добавлять юзера в чат
@dp.callback_query_handler(text = 'add_2_group')
async def addgroup(callback: types.CallbackQuery):
await callback.answer('жмав')