Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
from .web_server import auth
from .web_activate import activate



if config.ENABLE_WEB:
# 开启web请修改authMS.py
app = get_bot().server_app
app.register_blueprint(auth)
app.register_blueprint(activate)


@on_command('充值帮助', aliases=('我要充钱','续费帮助','我要续费','👴要充钱'), only_to_me=False)
@on_command('充值帮助', aliases=('我要充钱', '续费帮助', '我要续费', '👴要充钱'), only_to_me=False)
async def reg_help_chat(session):
if session.event.detail_type == 'private':
msg = config.REG_HELP_PRIVATE
else:
msg = config.REG_HELP_GROUP
#else:
# 新版QQ已不在有discuss, 所有多人聊天都是群消息
# else:
# 新版QQ已不在有discuss, 所有多人聊天都是群消息
# return
await session.finish(msg)

Expand All @@ -32,7 +30,7 @@ async def master_help_chat(session):
if session.event.detail_type == 'group':
return
if session.event.user_id not in hoshino.config.SUPERUSERS:
await session.finish('只有主人才能查看此页帮助')
await session.finish('你又不是管理员你查你🐴呢')
await session.finish(config.ADMIN_HELP)


Expand Down
67 changes: 35 additions & 32 deletions admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
from .constant import config



@on_command('变更所有授权', aliases=('批量变更', '批量授权'), only_to_me=False)
async def add_time_all_chat(session):
'''
"""
为所有已有授权的群增加授权x天, 可用于维护补偿时间等场景
'''
"""
if session.event.user_id not in hoshino.config.SUPERUSERS:
util.log(f'{session.event.user_id}尝试批量授权, 已拒绝')
await session.finish('只有主人才能批量授权哦')
await session.finish('你又不是老子的骂死塔你批量授权个🔨')
return
if not session.current_arg:
await session.finish('请发送需要为所有群增加或减少的长, 例如“变更所有授权 7”')
Expand All @@ -33,17 +32,17 @@ async def add_time_all_chat(session):

@on_command('授权列表', aliases=('查看授权列表', '查看全部授权', '查询全部授权'), only_to_me=True)
async def group_list_chat(session):
'''
"""
此指令获得的是, 所有已经获得授权的群, 其中一些群可能Bot并没有加入 \n
分页显示, 请在authMS.py中配置
'''
"""
if session.event.user_id not in hoshino.config.SUPERUSERS:
util.log(f'{session.event.user_id}尝试查看授权列表, 已拒绝')
await session.finish('只有主人才能查看授权列表哦')
await session.finish('你又不是老子的骂死塔你看你大爷')
return
if session.event.detail_type == 'group':
# 群聊查看授权列表你也是个小天才
await session.finish('请超级管理员私聊机器人查看授权列表')
await session.finish('群聊查看授权列表?你也是真个天才')

if not session.current_arg.strip():
# 无其他参数默认第一页
Expand Down Expand Up @@ -92,7 +91,7 @@ async def add_time_chat(session):

if session.event.user_id not in hoshino.config.SUPERUSERS:
util.log(f'{session.event.user_id}尝试为群{gid}增加{days}天授权, 已拒绝')
await session.finish('只有主人才能变更授权哦')
await session.finish('你又不是老子的骂死塔你改个p')
return

result = await util.change_authed_time(gid, days)
Expand All @@ -101,7 +100,6 @@ async def add_time_chat(session):
await session.finish(msg)



@on_command('转移授权', only_to_me=False)
async def group_change_chat(session):
if not session.current_arg:
Expand All @@ -116,27 +114,29 @@ async def group_change_chat(session):

if session.event.user_id not in hoshino.config.SUPERUSERS:
util.log(f'{session.event.user_id}尝试转移授权{old_gid}到{new_gid}, 已拒绝')
session.finish('只有主人才能转移授权哦')
session.finish('又不是老子的骂死塔,还想转移?想p吃呢')
return

gtime_old = util.check_group(old_gid)
if gtime_old == 0:
await session.finish('旧群无授权, 不可进行转移')
if old_gid == new_gid:
await session.finish('宁搁这儿原地TP呢?')

await util.transfer_group(old_gid, new_gid)
gtime_new = util.check_group(new_gid)
msg = await util.process_group_msg(new_gid,expiration=gtime_new, title=f'旧群{old_gid}授权已清空, 新群授权状态:\n')
msg = await util.process_group_msg(new_gid, expiration=gtime_new, title=f'旧群{old_gid}授权已清空, 新群授权状态:\n')
await notify_group(group_id=old_gid, txt=f'机器人管理员已转移本群授权时长至其他群。')

await session.finish(msg)


# noinspection PyUnboundLocalVariable
@on_command('授权状态', only_to_me=False)
async def auth_status_chat(session):
if session.event.user_id not in hoshino.config.SUPERUSERS:
util.log(f'{session.event.user_id}尝试查看授权状态, 已拒绝')
await session.finish('只有主人才能查看授权状态哦')
await session.finish('你又不是老子的骂死塔你查个🥚🥚')
return
for sid in hoshino.get_self_ids():
sgl = set(g['group_id']
Expand All @@ -154,18 +154,18 @@ async def auth_status_chat(session):

@on_command('清除授权', aliases=('删除授权', '移除授权', '移除群授权', '删除群授权'), only_to_me=True)
async def remove_auth_chat(session):
'''
"""
完全移除一个群的授权 \n
不需要二次确认, 我寻思着你rm /* -rf的时候也没人让你二次确认啊 \n
'''
"""
if not session.current_arg.strip():
await session.finish('请输入正确的群号, 例如“清除授权 123456789”')
gid = int(session.current_arg.strip())
time_left = util.check_group(gid)

if session.event.user_id not in hoshino.config.SUPERUSERS:
util.log(f'{session.event.user_id}尝试为群{gid}清除授权, 已拒绝')
await session.finish('只有主人才能清除授权哦')
await session.finish('你不是骂死塔还想删授权,是不是要老子把你🐴删了')

if not time_left:
await session.finish('此群未获得授权')
Expand All @@ -178,11 +178,12 @@ async def remove_auth_chat(session):
await session.send(msg)


@on_command('不检查人数', aliases=('设置人数白名单'), only_to_me=False)
# noinspection PyUnboundLocalVariable
@on_command('不检查人数', aliases='设置人数白名单', only_to_me=False)
async def no_number_check_chat(session):
'''
"""
不检查一个群的人数是否超过人数限制, 在群聊中发送则为不检查本群
'''
"""
if session.event.detail_type == 'group':
gid = session.event.group_id
elif session.event.detail_type == 'private':
Expand All @@ -193,7 +194,7 @@ async def no_number_check_chat(session):
uid = session.event.user_id
if uid not in hoshino.config.SUPERUSERS:
util.log(f'{uid}尝试为群{gid}清除设置不检查人数, 已拒绝')
await session.finish('只有主人才能设置白名单')
await session.finish('你不是主人你设你个大头鬼的人数白名单')
return

util.allowlist(group_id=gid, operator='add', nocheck='no_number_check')
Expand All @@ -202,7 +203,8 @@ async def no_number_check_chat(session):
await session.finish(f'已将群{gid}添加至白名单, 类型为不检查人数')


@on_command('不检查授权', aliases=('设置授权白名单'), only_to_me=False)
# noinspection PyUnboundLocalVariable
@on_command('不检查授权', aliases='设置授权白名单', only_to_me=False)
async def no_auth_check_chat(session):
if session.event.detail_type == 'group':
gid = session.event.group_id
Expand All @@ -214,19 +216,20 @@ async def no_auth_check_chat(session):
uid = session.event.user_id
if uid not in hoshino.config.SUPERUSERS:
util.log(f'{uid}尝试为群{gid}清除设置不检查授权, 已拒绝')
await session.finish('只有主人才能设置白名单')
await session.finish('你不是主人你设你个大头鬼的授权白名单')
return
util.allowlist(group_id=gid, operator='add', nocheck='no_auth_check')
util.log(f'已将群{gid}添加至白名单, 类型为不检查授权')
await notify_group(group_id=gid, txt='机器人管理员已添加本群为白名单,将不会检查本群授权是否过期。')
await session.finish(f'已将群{gid}添加至白名单, 类型为不检查授权')


# noinspection PyUnboundLocalVariable
@on_command('添加白名单', only_to_me=False)
async def no_check_chat(session):
'''
"""
最高级别白名单, 授权与人数都检查
'''
"""
if session.event.detail_type == 'group':
gid = session.event.group_id
elif session.event.detail_type == 'private':
Expand All @@ -237,7 +240,7 @@ async def no_check_chat(session):
uid = session.event.user_id
if uid not in hoshino.config.SUPERUSERS:
util.log(f'{uid}尝试为群{gid}清除设置添加白名单, 已拒绝')
await session.finish('只有主人才能设置白名单')
await session.finish('不是主人还想设白名单?你是不是憨批')
return

util.allowlist(group_id=gid, operator='add', nocheck='no_check')
Expand All @@ -246,7 +249,7 @@ async def no_check_chat(session):
await session.finish(f'已将群{gid}添加至白名单, 类型为全部不检查')


@on_command('移除白名单', aliases=('删除白名单'))
@on_command('移除白名单', aliases='删除白名单')
async def remove_allowlist_chat(session):
if not session.current_arg.strip():
await session.finish('请输入正确的群号, 例如“移除白名单 123456789”')
Expand All @@ -255,7 +258,7 @@ async def remove_allowlist_chat(session):

if uid not in hoshino.config.SUPERUSERS:
util.log(f'{uid}尝试移除白名单{gid}, 已拒绝')
await session.finish('只有主人才能移除白名单')
await session.finish('不是主人还想设白名单?你是不是憨批')
return

re_code = util.allowlist(group_id=gid, operator='remove')
Expand All @@ -270,7 +273,7 @@ async def remove_allowlist_chat(session):
async def get_allowlist_chat(session):
if session.event.user_id not in hoshino.config.SUPERUSERS:
util.log(f'{session.event.user_id}尝试查看白名单, 已拒绝')
await session.finish('只有主人才能查看白名单')
await session.finish('不是主人还想看白名单?你是不是憨批')
return

allow_list = util.get_list(list_type='allowlist')
Expand All @@ -285,15 +288,15 @@ async def get_allowlist_chat(session):
gname = gname_dir[gid]
gnocheck = allow_list[gid]
msg += f'群名:{gname}\n类型:{gnocheck}\n\n'
i = i+1
i = i + 1
session.finish(msg)


@on_command('刷新事件过滤器')
async def reload_ef(session):
if session.event.user_id not in hoshino.config.SUPERUSERS:
util.log(f'{session.event.user_id}刷新事件过滤器, 已拒绝')
await session.finish('只有主人才能刷新事件过滤器')
await session.finish('刷你🐴,给👴爪巴')
return
await util.flush_group()
await session.send("刷新成功!")
5 changes: 4 additions & 1 deletion authMS.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class auth_config(object):

# 提醒/检查的时间间隔, 单位小时,
# 值为1, 意为每小时检查一次, 注意实际每天的检查次数会向下取整
FREQUENCY = 6
# 修改:以下为时间间隔,从上往下依次是小时,分钟,秒
FREQUENCY_H = 8
FREQUENCY_M = 0
FREQUENCY_S = 0

# ----------------------授权列表与卡密列表----------------------------

Expand Down
Loading