AddOneSecondL / pcrjjc2-clanbattle

基于pcrjjc2通信的会战推送插件(DLC了属于是
GNU Affero General Public License v3.0
23 stars 6 forks source link

大佬能不能让这个插件运行起来,插件列表可以显示就是用不了 #35

Open duoshoumiao opened 1 year ago

duoshoumiao commented 1 year ago

from hoshino import Service, priv from random import sample

sv = Service('抽奖', visible=False, enable_on_default=False)

participants = [] # 参与者列表

@sv.on_command('set_lottery', aliases=('设置抽奖',)) async def set_lottery(bot, ev): args = ev.message.extract_plain_text().split() # 提取参数

if len(args) != 2:  # 参数个数错误
    await bot.send(ev, '参数错误,请按照格式输入参与人数和奖项数目(示例:设置抽奖 10 3)')
    return

try:
    participant_count = int(args[0])  # 参与人数
    prize_count = int(args[1])  # 奖项数目
except ValueError:
    await bot.send(ev, '参数错误,请输入有效的数字')
    return

# 在这里编写设置参与人数和奖项的逻辑
# 例如,您可以将参与人数和奖项数保存到数据库中,以便后续使用

await bot.send(ev, f'抽奖设置成功!参与人数:{participant_count},奖项数目:{prize_count}')

@sv.on_command('start_lottery', aliases=('开始抽奖',)) async def start_lottery(bot, ev):

在这里编写开始抽奖的逻辑

# 例如,您可以从数据库中获取参与人数和奖项数,然后进行抽奖操作

await bot.send(ev, '抽奖已经开始!')

# 编写抽奖逻辑并生成中奖名单
winners = sample(participants, prize_count)

await bot.send(ev,  f'抽奖已经完成!中奖名单:{", ".join(winners)}')

@sv.on_command('join_lottery', aliases=('参与抽奖',)) async def join_lottery(bot, ev): if ev.group_id: # 在群里 if ev.user_id not in participants: participants.append(ev.user_id) await bot.send(ev, '参与成功!') else: await bot.send(ev, '您已经参与过抽奖了!') else: await bot.send(ev, '此命令只能在群里使用!', at_sender=True)

@sv.on_command('participants', aliases=('参与者',)) @priv.check_privilege(priv.SUPERUSER) async def list_participants(bot, ev):

显示当前的参与者列表

participant_list = ', '.join(str(p) for p in participants)
await bot.send(ev, f'当前参与者:{participant_list}')
AddOneSecondL commented 1 year ago

enable_on_default=False,开启的时候启用了吗,还没看下面的内容

duoshoumiao commented 1 year ago

enable_on_default=False,开启的时候启用了吗,还没看下面的内容

[2023-10-22 17:23:38,091 nonebot] ERROR: Failed to import and load "hoshino.modules.qunchoujiang.qunchoujiang", error: module 'hoshino.priv' has no attribute 'check_privilege' [2023-10-22 17:23:38,091 nonebot] ERROR: module 'hoshino.priv' has no attribute 'check_privilege' Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\nonebot\plugin.py", line 419, in _load_plugin module = importlib.import_module(module_path) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\importlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\Administrator\Desktop\HoshinoBot-master - 1\HoshinoBot-master\hoshino\modules\qunchoujiang\qunchoujiang.py", line 52, in @priv.check_privilege(priv.SUPERUSER) AttributeError: module 'hoshino.priv' has no attribute 'check_privilege' 他只报错这个

duoshoumiao commented 1 year ago

image 使用是没反应的

AddOneSecondL commented 1 year ago

'hoshino.priv' has no attribute 'check_privilege',可能是新版或者旧版的hos没有check_privilege这个函数,如果不需要管理权限的话注释掉这段就好了

duoshoumiao commented 1 year ago

image

'hoshino.priv' has no attribute 'check_privilege',可能是新版或者旧版的hos没有check_privilege这个函数,如果不需要管理权限的话注释掉这段就好了

删掉了

duoshoumiao commented 1 year ago

image

AddOneSecondL commented 1 year ago

去找一下on_command的写法,这少参数了

AddOneSecondL commented 1 year ago

在hoshinobot项目里面搜一下on_command能找着

duoshoumiao commented 1 year ago

去找一下on_command的写法,这少参数了

搞定乐