Skip to content

Commit

Permalink
🚨v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Reversedeer authored Mar 5, 2023
1 parent ef70092 commit 2d6cc07
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 33 deletions.
46 changes: 35 additions & 11 deletions nonebot_plugin_eventmonitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,28 @@
Bot, Event, Message,
PokeNotifyEvent,
HonorNotifyEvent,
GroupMessageEvent,
GroupUploadNoticeEvent,
GroupDecreaseNoticeEvent,
GroupIncreaseNoticeEvent,
GroupAdminNoticeEvent,
LuckyKingNotifyEvent
)

from .chuoyichuo import chuo_send_msg
from .rongyu import monitor_rongyu
from .stamp import *
from .honour import *
from .admin import *


try:
cd_time = nonebot.get_driver().config.cd_time # 从配置文件中读取cd_time
except:
cd_time = 0 # cd默认值

chuo_cd_dir = {}

# 获取戳一戳状态
async def _is_poke(bot: Bot, event: Event, state: T_State) -> bool:
async def _is_poke(event: Event, state: T_State) -> bool:
return isinstance(event, PokeNotifyEvent) and event.is_tome()


Expand Down Expand Up @@ -56,36 +64,52 @@ async def _is_red_packet(bot: Bot, event: Event, state: T_State) -> bool:
# 戳一戳
chuo = on_notice(Rule(_is_poke), priority=50, block=True)
# 群荣誉
rongyu = on_notice(Rule(_is_rongyu), priority=50, block=True)
qrongyu = on_notice(Rule(_is_rongyu), priority=50, block=True)
# 群文件
files = on_notice(Rule(_is_checker), priority=50, block=True)
# 群员减少
del_user = on_notice(Rule(_is_del_user), priority=50, block=True)
# 群员增加
add_user = on_notice(Rule(_is_add_user), priority=50, block=True)
# 群管理
admin = on_notice(Rule(_is_admin_change), priority=50, block=True)
group_admin = on_notice(Rule(_is_admin_change), priority=50, block=True)
# 红包
red_packet = on_notice(Rule(_is_red_packet), priority=50, block=True)


@chuo.handle()
async def send_chuo(bot: Bot, event: Event, state: T_State):
if bot_name == "寄":
await chuo.finish("请先配置bot_name")
uid = event.get_user_id() # 获取用户id
try:
cd = event.time - chuo_cd_dir[uid] # 计算cd
except KeyError:
cd = cd_time + 1 # 没有记录则cd为cd_time+1
if (
cd > cd_time
or event.get_user_id() in nonebot.get_driver().config.superusers
): # 记录cd
chuo_cd_dir.update({uid: event.time})
rely_msg = chuo_send_msg()
await chuo.finish(message=Message(rely_msg))


@rongyu.handle()
@qrongyu.handle()
async def send_rongyu(bot: Bot, event: HonorNotifyEvent, state: T_State):
if bot_qq == "寄":
await qrongyu.finish("请先配置bot_qq")
if super_qq == "寄":
await qrongyu.finish("请先配置SUPERUSERS")
rely_msg = monitor_rongyu(event.honor_type, event.user_id)
await send_rongyu.finish(message=Message(rely_msg))
await qrongyu.finish(message=Message(rely_msg))


@files.handle()
async def handle_first_receive(bot: Bot, event: GroupUploadNoticeEvent, state: T_State):
rely = f'[CQ:at,qq={event.user_id}]\n' \
f'[CQ:image,file=https://q4.qlogo.cn/headimg_dl?dst_uin={event.user_id}&spec=640]' \
f'\n 上传了新文件,感谢你一直为群里做贡献[CQ:face,id=175]'
f'\n 上传了新文件,感谢你一直为群里做贡献喵~[CQ:face,id=175]'
await files.finish(message=Message(rely))


Expand All @@ -101,10 +125,10 @@ async def user_welcome(bot: Bot, event: GroupIncreaseNoticeEvent, state: T_State
await add_user.finish(message=Message(rely_msg))


@admin.handle()
@group_admin.handle()
async def admin_chance(bot: Bot, event: GroupAdminNoticeEvent, state: T_State):
rely_msg = admin_change(event.sub_type, event.user_id)
await bot.finish(message=Message(rely_msg))
rely_msg = admin_changer(event.sub_type, event.user_id)
await group_admin.finish(message=Message(rely_msg))

@red_packet.handle()
async def hongbao(bot: Bot, event: LuckyKingNotifyEvent, state: T_State):
Expand Down
31 changes: 12 additions & 19 deletions nonebot_plugin_eventmonitor/admin.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
from datetime import datetime
from .honour import bot_qq, super_qq

# 机器人QQ号
bot_qq = 3035332291
# 开发者QQ号
super_qq = [2782383376]
# 退群消息
del_user_msg = ""
# 入群消息
add_user_msg = ""


def admin_change(sub_type, user_id):
def admin_changer(sub_type, user_id):
admin_msg = ""
if sub_type == "set":
if user_id == bot_qq:
admin_msg = f"芜湖,咱以后也是管理了~"
admin_msg = f"我也是管理啦,你们要小心喵~"
else:
admin_msg = f"恭喜[CQ:at,qq={user_id}]喜提本群管理~"
admin_msg = f"恭喜[CQ:at,qq={user_id}]喜提本群管理喵~"
elif sub_type == "unset":
if user_id == bot_qq:
admin_msg = f"呜呜,别下咱管理呀QwQ"
admin_msg = f"呜呜,别下咱管理呀QwQ,喵呜~"
else:
admin_msg = f"[CQ:at,qq={user_id}]痛失本群管理~"
admin_msg = f"[CQ:at,qq={user_id}]痛失本群管理喵~"
return admin_msg


def del_user_bye(add_time, group_id, user_id):
global groups_all, del_user_msg
del_time = datetime.fromtimestamp(add_time)
if user_id in super_qq:
del_user_msg = f"<{del_time}>@{user_id}恭送主人离开~"
del_user_msg = f"<{del_time}>@{user_id}恭送主人离开喵~"
else:
del_user_msg = f"<{del_time}>QQ号为:{user_id}的小可爱退群咯,good bye呀,永别了这位朋友~" \
del_user_msg = f"<{del_time}>QQ号为:{user_id}的小可爱退群喵~" \
f"[CQ:image,file=https://q4.qlogo.cn/headimg_dl?dst_uin={user_id}&spec=640]"
return del_user_msg

Expand All @@ -40,11 +33,11 @@ def add_user_wecome(add_time, group_id, user_id):
global groups_all, add_user_msg
add_time = datetime.fromtimestamp(add_time)
if user_id == bot_qq:
add_user_msg = f"唔,很荣幸受邀进入贵群~\n" \
f"嘤嘤嘤呜呜呜"
add_user_msg = f"本喵被邀进入贵群喵~\n" \
f"火速上个管理喵~"
elif user_id in super_qq:
add_user_msg = f"[CQ:at,qq={user_id}]欢迎主人进群[CQ:face,id=175]"
add_user_msg = f"[CQ:at,qq={user_id}]欢迎主人进群喵~[CQ:face,id=175]"
else:
add_user_msg = f"欢迎[CQ:at,qq={user_id}]的加入,加入时间:{add_time}请在群内积极发言哦~" \
add_user_msg = f"欢迎[CQ:at,qq={user_id}]的加入喵~,加入时间:{add_time}请在群内积极发言喵~" \
f"[CQ:image,file=https://q4.qlogo.cn/headimg_dl?dst_uin={user_id}&spec=640]"
return add_user_msg
42 changes: 42 additions & 0 deletions nonebot_plugin_eventmonitor/honour.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import nonebot


try:
bot_qq = nonebot.get_driver().config.bot_qq
except:
bot_qq = "寄"

try:
super_qq = nonebot.get_driver().config.superusers
except:
super_qq = "寄"



def monitor_rongyu(honor_type, user_id):
rely = ""

if honor_type == "talkative":
if user_id == bot_qq:
rely = f"你们又不行了,本喵喜提龙王~"
elif user_id == super_qq:
rely = f"[CQ:at,qq={user_id}]恭喜主人荣获龙王标识喵~"
else:
rely = f"恭喜[CQ:at,qq={user_id}]荣获龙王标识喵~"

elif honor_type == "performer":
if user_id == bot_qq:
pass
elif user_id == super_qq:
rely = f"[CQ:at,qq={user_id}]恭喜主人荣获群聊之火标识喵~"
else:
rely = f"恭喜[CQ:at,qq={user_id}]荣获群聊之火标识喵~"

elif honor_type == "emotion":
if user_id == bot_qq:
pass
elif user_id == super_qq:
rely = f"[CQ:at,qq={user_id}]恭喜主人荣获快乐源泉标识喵~"
else:
rely = f"恭喜[CQ:at,qq={user_id}]荣获快乐源泉标识喵~"
return rely
42 changes: 42 additions & 0 deletions nonebot_plugin_eventmonitor/stamp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import random
import nonebot


try:
bot_name = nonebot.get_driver().config.bot_name
except:
bot_name = "寄"


def chuo_send_msg():
rand_num = random.randint(0, len(chuo_msg) - 1)
return chuo_msg[rand_num]


chuo_msg = [
f"别戳了,{bot_name}怕疼QwQ",
f"呜呜,再戳{bot_name}脸都要肿了",
f"戳坏了{bot_name},你赔得起吗?",
f"再戳{bot_name},我要叫我主人了",
f"别老戳{bot_name}了,您歇会吧~",
f"再戳{bot_name},咬你了嗷~",
f"想好了再戳,(*-`ω´-)✄",
f"喂,110吗,有人老戳我",
f"嗷呜嗷呜...恶龙咆哮┗|`O′|┛",
f"有事恁叫我,别天天一个劲戳戳戳!",
f"再戳我让你变成女人,嘿嘿",
f"不要戳我了 >_<",
f"不要这样子啦(*/ω\*)",
f"不要再戳了(害怕ing)",
f"还戳,哼(つд⊂)(生气)",
f"再戳,小心我顺着网线找你.",
f"咱要型气了o(>﹏<)o",
f"嘿嘿,好舒服呀(bushi)",
f"乖,好了好了,别戳了~",
f"我爪巴爪巴,球球别再戳了",
f"别再戳我了,行🐎?!",
f"啊呜,你有什么事吗?"
]



8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

setuptools.setup(
name="nonebot_plugin_eventmonitor",
version="0.0.6",
version="0.1.0",
author="schwarzwald",
description="监控群事件的插件,支持戳一戳,成员变动,群荣誉变化等提示",
description="监控群事件的插件,支持戳一戳,成员变动,群荣誉,运气王变化等提示",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Reversedeer/nonebot_plugin_eventmonitor",
Expand All @@ -22,6 +22,8 @@
packages=setuptools.find_packages(),
python_requires=">=3.8",
install_requires = [
'nonebot2>=2.0.0rc1', 'nonebot-adapter-onebot>=2.2.0'
'nonebot2>=2.0.0rc2',
'nonebot-adapter-onebot',
'requests>=2.28.2'
]
)

0 comments on commit 2d6cc07

Please sign in to comment.