Compare commits
No commits in common. "102d52cd5b4db45e1c98005b5b44b1a6472811ad" and "7a4d9982618b066b6d50edaab39f6da801dffed7" have entirely different histories.
102d52cd5b
...
7a4d998261
6 changed files with 7 additions and 72 deletions
|
@ -12,7 +12,6 @@ from aiogram import F
|
|||
|
||||
from core.bitflip import handle_bitflip_command
|
||||
from core.link import handle_links
|
||||
from core.promote import handle_promote_command
|
||||
from core.repeater import MessageRepeater
|
||||
from core.simple import handle_start_command, handle_baka, dummy_handler, handle_info_command
|
||||
from core.actions import handle_actions, handle_reverse_actions
|
||||
|
@ -40,8 +39,6 @@ class TelegramAdapter:
|
|||
router.message(Command('info'))(handle_info_command)
|
||||
# bitflip 模块
|
||||
router.message(Command('bitflip'))(handle_bitflip_command)
|
||||
# promote 模块
|
||||
router.message(Command('t'))(handle_promote_command)
|
||||
# stats 模块
|
||||
router.message(Command('stats'))(handle_stats_command)
|
||||
# unpin 模块
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# 管理员对应的 Telegram 用户 ID
|
||||
# 你可以通过 /info 命令获取你的用户 ID
|
||||
admin: 123456789
|
||||
admin: 616760897
|
||||
|
||||
# global features settings
|
||||
features:
|
||||
|
@ -13,9 +11,6 @@ features:
|
|||
# 启用链接解析/清理
|
||||
link:
|
||||
enable: true
|
||||
# 启用互送头衔
|
||||
promote:
|
||||
enable: true
|
||||
# 启用复读
|
||||
repeater:
|
||||
enable: true
|
||||
|
|
|
@ -4,7 +4,7 @@ from pathlib import Path
|
|||
|
||||
|
||||
class Config:
|
||||
def __init__(self, config_path: str = "config.yaml"):
|
||||
def __init__(self, config_path: str = "config.example.yaml"):
|
||||
self.config_path = Path(config_path)
|
||||
self.config_data = self._load_config()
|
||||
|
||||
|
|
|
@ -53,19 +53,10 @@ class MessageStatsMiddleware(BaseMiddleware):
|
|||
if not self.stats[chat_id]['users'][user_id]['xm_count']:
|
||||
self.stats[chat_id]['users'][user_id]['xm_count'] = 0
|
||||
self.stats[chat_id]['users'][user_id]['xm_count'] += 1
|
||||
if event.sticker and event.sticker.file_unique_id in ['AQADhhcAAs1rgFVy']:
|
||||
if not self.stats[chat_id]['users'][user_id]['xm_count']:
|
||||
self.stats[chat_id]['users'][user_id]['xm_count'] = 0
|
||||
self.stats[chat_id]['users'][user_id]['xm_count'] += 1
|
||||
|
||||
if event.text and '我菜' in event.text:
|
||||
if not self.stats[chat_id]['users'][user_id]['wocai_count']:
|
||||
self.stats[chat_id]['users'][user_id]['xm_count'] = 0
|
||||
self.stats[chat_id]['users'][user_id]['wocai_count'] += 1
|
||||
if event.sticker and event.sticker.file_unique_id in ['AQAD6AUAAgGeUVZy']:
|
||||
if not self.stats[chat_id]['users'][user_id]['wocai_count']:
|
||||
self.stats[chat_id]['users'][user_id]['wocai_count'] = 0
|
||||
self.stats[chat_id]['users'][user_id]['wocai_count'] += 1
|
||||
# 保存统计数据
|
||||
self.save_stats()
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
from aiogram.exceptions import TelegramBadRequest
|
||||
from aiogram.types import Message
|
||||
|
||||
from config import config
|
||||
|
||||
|
||||
async def handle_promote_command(message: Message) -> None:
|
||||
title = message.text.replace('/t', '').strip()
|
||||
if not config.is_feature_enabled('promote', message.chat.id):
|
||||
return
|
||||
if message.chat.type not in ['group', 'supergroup']:
|
||||
return
|
||||
try:
|
||||
if not message.reply_to_message:
|
||||
await message.reply('咱不知道给谁头衔呢')
|
||||
return
|
||||
if not title:
|
||||
await message.reply('咱不知道给什么头衔呢')
|
||||
return
|
||||
else:
|
||||
member = await message.chat.get_member(message.reply_to_message.from_user.id)
|
||||
if len(title) > 16:
|
||||
await message.reply('头衔太长了,咱设置不了')
|
||||
return
|
||||
if member.status == 'creator':
|
||||
await message.reply('咱不能给群主设置头衔')
|
||||
return
|
||||
if not member.status in ['administrator','creator']:
|
||||
await message.chat.promote(message.reply_to_message.from_user.id,can_manage_chat=True)
|
||||
await message.chat.set_administrator_custom_title(message.reply_to_message.from_user.id,title)
|
||||
await message.reply(
|
||||
f'{message.from_user.mention_html()} 把 {message.reply_to_message.from_user.mention_html()} 变成了 <b>{title}</b>!',
|
||||
parse_mode='HTML')
|
||||
elif member.status == 'administrator' and member.can_be_edited:
|
||||
await message.chat.set_administrator_custom_title(message.reply_to_message.from_user.id,title)
|
||||
await message.reply(
|
||||
f'{message.from_user.mention_html()} 把 {message.reply_to_message.from_user.mention_html()} 变成了 <b>{title}</b>!',
|
||||
parse_mode='HTML')
|
||||
else:
|
||||
await message.reply('咱不能给这个人设置头衔,可能是因为ta已经被其它管理员设置了头衔')
|
||||
return
|
||||
except TelegramBadRequest as e:
|
||||
await message.reply(f'因为咱没有添加新的管理员的权限,咱没办法设置头衔')
|
||||
return
|
||||
except Exception as e:
|
||||
await message.reply(f'发生了错误: {str(e)}')
|
||||
return
|
||||
|
|
@ -30,12 +30,12 @@ async def handle_stats_command(message: Message):
|
|||
)
|
||||
sorted_most_xm_users = sorted(
|
||||
stats['users'].items(),
|
||||
key=lambda x: x[1].get('xm_count',0),
|
||||
key=lambda x: x[1]['xm_count'],
|
||||
reverse=True
|
||||
)
|
||||
sorted_most_wocai_users = sorted(
|
||||
stats['users'].items(),
|
||||
key=lambda x: x[1].get('wocai_count',0),
|
||||
key=lambda x: x[1]['wocai_count'],
|
||||
reverse=True
|
||||
)
|
||||
|
||||
|
@ -48,13 +48,13 @@ async def handle_stats_command(message: Message):
|
|||
for i, (user_id, user_data) in enumerate(sorted_users[:10], 1):
|
||||
name = user_data['name'] or user_data['username'] or str(user_id)
|
||||
text += f"{i}. {name}: {user_data['message_count']} 条\n"
|
||||
if sorted_most_xm_users and any(user_data['xm_count'] > 0 for _, user_data in sorted_most_xm_users):
|
||||
text += "\n🍋 羡慕统计:\n"
|
||||
if sorted_most_xm_users:
|
||||
text += "\n💬 羡慕统计:\n"
|
||||
for user_id, user_data in sorted_most_xm_users:
|
||||
if user_data['xm_count'] > 0:
|
||||
name = user_data['name'] or user_data['username'] or str(user_id)
|
||||
text += f"{name}: {user_data['xm_count']} 次羡慕\n"
|
||||
if sorted_most_wocai_users and any(user_data['wocai_count'] > 0 for _, user_data in sorted_most_wocai_users):
|
||||
if sorted_most_wocai_users:
|
||||
text += "\n🥬 卖菜统计:\n"
|
||||
for user_id, user_data in sorted_most_wocai_users:
|
||||
if user_data['wocai_count'] > 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue