Skip to content

Commit

Permalink
删除了一些过时的文件,为一些功能添加开关和群组控制,添加是否自动生成帮助的开关,更新config
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoRabi committed Jul 29, 2023
1 parent da72ee7 commit 5230d67
Show file tree
Hide file tree
Showing 23 changed files with 284 additions and 77 deletions.
51 changes: 28 additions & 23 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ adapter: # Mirai-Api-Http
verify_key: NekoRabi

botconfig:
botname: '' # 机器人名字
qq: 123456 # 机器人QQ
botname: "" # 机器人名字
qq: 123456 # 机器人QQ

admin: # 以下都是管理员
- 1215791340
Expand All @@ -19,48 +19,53 @@ blacklist: # 黑名单
mutegrouplist:
- 0

commandpre: '' # 指令前缀
commandpre: "" # 指令前缀

master: 0 # 机器人主人,必填
master: 0 # 机器人主人,必填

replyimgpath : fox # 表情包路径
replyimgpath: fox # 表情包路径

loglevel: INFO # 日志等级

# "戳一戳"配置文件
nudgeconfig:
# 在某群禁用 摸头事件
disnudgegroup:
- 0
sendnudgechance: 1 # 被戳时 以 "戳一戳" 还击的概率
- 469789730
- 586468489
sendnudgechance: 1 # 被戳时 以 "戳一戳" 还击的概率
supersendnudgechance: 0.2 # 还击的"戳一戳"中,触发超级还击的概率
supernudgequantity: 10 # 单次超级还击的发送 "戳一戳" 的次数

# 在某群关闭自动回复
norepeatgroup:
- 0
- 586468489

silencegroup:
- 0 # 设置单群沉默
- 586468489 # 设置单群沉默

welcomeinfo: # 新人入群欢迎词,%ps%为新人名字,%gn%为群聊名字
welcomeinfo: # 新人入群欢迎词,%ps%为新人名字,%gn%为群聊名字
- 欢迎%ps%加入%gn%

no_welcome:
- 586468489

whitelist:
- 0 # 白名单
- 1215791340 # 白名单

trash_folders: # 需要清理垃圾的文件夹
- './images/MajSoulInfo'
- './images/PetPet'
- './images/Remake'
- './images/ImgGenerator'
- "./images/MajSoulInfo"
- "./images/PetPet"
- "./images/Remake"
- "./images/ImgGenerator"

settings: # 功能开关
autogetpaipu: true # 自动获取雀魂牌谱
autowelcome: true # 自动欢迎新人
nudgereply: true # 是否启用摸头事件
r18talk: true # 开启管理员词库
silence: false # 全局沉默,降低发言频率
norepeat: false # 全局自动回复
help: true # 是否显示帮助
saveflashimg: false # 保存闪照
autogetpaipu: true # 自动获取雀魂牌谱
autowelcome: true # 自动欢迎新人
nudgereply: true # 是否启用摸头事件
r18talk: true # 开启管理员词库
silence: false # 全局沉默,降低发言频率
norepeat: false # 全局自动回复
help: true # 是否显示帮助
# saveflashimg: false # 保存闪照
general_help: true # 自动生成帮助图片
28 changes: 24 additions & 4 deletions core/fun/roll.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,35 @@ async def roll_item(event: GroupMessage or FriendMessage):
if m2:
return await messagechain_sender(event=event, msg=await messagechain_builder(
text=f'{_random_int_general(m2.group(1), m2.group(2))}'))
m3 = re.match(r'[Dd](\d+)$', content)
m3 = re.match(r'(\d+)?[Dd](\d+)$', content)
if m3:
dice = int(m3.group(1))
counts = m3.group(1)
if counts:
counts = int(counts)
else:
counts = 1
if counts < 1:
counts = 1
elif counts > 100:
return await messagechain_sender(event=event, msg=await messagechain_builder(at=event.sender.id, text='我累了'))
dice = int(m3.group(2))
if dice < 1 or dice > 100:
return await messagechain_sender(event=event, msg=await messagechain_builder(at=event.sender.id, text='我没有这样的骰子'))
elif dice % 2 == 1 and dice > 9:
return await messagechain_sender(event=event, msg=await messagechain_builder(at=event.sender.id, text='我只有10面以下的奇数面骰子~'))
each_rnd = _random_int_general(dn=dice)
sum = each_rnd
rnd_str = f'{each_rnd}'
for i in range(counts):
if i == 0:
continue
each_rnd = _random_int_general(dn=dice)
sum += each_rnd
rnd_str += f' + {each_rnd}'
rnd_str += f' = {sum}'

return await messagechain_sender(event=event, msg=await messagechain_builder(
text=f'{_random_int_general(dn=dice)}'))
text=f'{rnd_str}'))
m4 = content.split(' ')
return await messagechain_sender(event=event, msg=await messagechain_builder(text=_random_item(m4)))
return await messagechain_sender(event=event, msg=await messagechain_builder(text=f'{_random_int_general()}'))
Expand All @@ -107,7 +127,7 @@ async def roll_item(event: GroupMessage or FriendMessage):
"roll 正整数a : 返回 0-a 的随机整数 ",
"roll a-b : 返回 a-b 之间的随机整数",
"roll itemA itemB …… : 返回随机一个元素",
"roll dn: 投掷n面骰"
"roll ndn: 投掷n次n面骰"
]
add_help('group', [
'roll 返回100以内的随机整数',
Expand Down
2 changes: 2 additions & 0 deletions core/fun/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async def welcome(event: MemberJoinEvent) -> None:
personname = event.member.member_name
groupname = event.member.group.name
groupid = event.member.group.id
if groupid in config.get('no_welcome', []):
return
info: str = random.choice(config['welcomeinfo'])
info = info.replace('%ps%', personname).replace('%gn%', groupname)
await messagechain_sender(
Expand Down
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
if __name__ == '__main__':

config = load_config()
create_helpimg()
if config.get('setting',{}).get('general_help',True):
create_helpimg()
settings = config['settings']
botname = config['botconfig']['botname']

Expand Down
Binary file removed other/自用mirai/mcl-2.1.1.zip
Binary file not shown.
11 changes: 9 additions & 2 deletions plugin/ImgGenerator/KissKiss/Kisskiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from moviepy.editor import ImageSequenceClip as imageclip
from io import BytesIO
from core import bot, commands_map, commandpre, blacklist
from utils import read_file
from utils.MessageChainBuilder import messagechain_builder
from utils.MessageChainSender import messagechain_sender

Expand All @@ -24,6 +25,8 @@

__all__ = ['on_kiss']

_cfg = read_file(r'./config/ImgGenerator/config.yml')


async def save_gif(gif_frames, dest, fps=10):
clip = imageclip(gif_frames, fps=fps)
Expand Down Expand Up @@ -87,6 +90,8 @@ async def kiss(operator_id, target_id) -> None:

@bot.on(GroupMessage)
async def on_kiss(event: GroupMessage):
if not _cfg.get('Kiss', True):
return
if event.sender.id in blacklist:
return
msg = "".join(map(str, event.message_chain[Plain]))
Expand All @@ -97,9 +102,11 @@ async def on_kiss(event: GroupMessage):
target_id = event.message_chain.get_first(At).target
if operator_id == target_id:
# return await bot.send(event, await messagechain_builder(text="请不要自交", rndimg=True))
return await messagechain_sender(event=event, msg= await messagechain_builder(text="请不要自交", rndimg=True, at=event.sender.id))
return await messagechain_sender(event=event, msg=await messagechain_builder(text="请不要自交", rndimg=True,
at=event.sender.id))
else:
await kiss(operator_id=operator_id, target_id=target_id)
# await bot.send(event, await messagechain_builder(
# imgpath=f'./images/ImgGenerator/KissKiss/tempKiss-{operator_id}-{target_id}.gif'))
return await messagechain_sender(event=event, msg= await messagechain_builder(imgpath=f'./images/ImgGenerator/KissKiss/tempKiss-{operator_id}-{target_id}.gif'))
return await messagechain_sender(event=event, msg=await messagechain_builder(
imgpath=f'./images/ImgGenerator/KissKiss/tempKiss-{operator_id}-{target_id}.gif'))
25 changes: 8 additions & 17 deletions plugin/ImgGenerator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import os

from .file_init import *
from core.help import add_help
from plugin.ImgGenerator.bwimg import *
from plugin.ImgGenerator.csgokill import *
from plugin.ImgGenerator.groupmember_imgoperation import *

if not os.path.exists('./images/ImgGenerator'):
os.mkdir(f'./images/ImgGenerator')
if os.path.exists(r'./main.exe'):
from plugin.ImgGenerator.KissKiss import *
from plugin.ImgGenerator.jupai import *
from plugin.ImgGenerator.prank_on_groupmember import *
else:
_plugins = os.listdir(r'./plugin/ImgGenerator')
for path in _plugins:
if os.path.isdir(f'./plugin/ImgGenerator/{path}'):
if os.path.exists(f'./plugin/ImgGenerator/{path}/__init__.py'):
exec(f'from plugin.ImgGenerator.{path} import *')
from .bwimg import *
from .csgokill import *
from .groupmember_imgoperation import *
from .jupai import *
from .KissKiss import *
from .prank_on_groupmember import *


add_help('group', [
Expand All @@ -27,6 +17,7 @@
"丢/举(我自己)@群友 : 把群友丢出去/举起来\n ",
"吃掉 @群友 : 把群友吃了\n",
"bw [<文本>] [<图片>] : 返回一张黑白处理后的图片,底部有一行文字\n",
"娶群友 : 不解释了\n",
"截图 <回复消息> : 将一条文本聊天记录截图\n",
"击杀[<文本> 或 @群友] : 击杀群友\n"
])
9 changes: 8 additions & 1 deletion plugin/ImgGenerator/bwimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

from core import bot, commandpre, blacklist

from utils.cfg_loader import read_file

__all__ = ['bwimg']

from utils.MessageChainBuilder import messagechain_builder
Expand All @@ -21,6 +23,8 @@
if not os.path.exists("./images/ImgGenerator"):
os.mkdir("./images/ImgGenerator")

_cfg = read_file(r'./config/ImgGenerator/config.yml')


def makebwimg(imgname, text: str = ""):
filename = os.path.splitext(imgname)[0]
Expand Down Expand Up @@ -61,6 +65,8 @@ def deletesource(imgname):

@bot.on(GroupMessage)
async def bwimg(event: GroupMessage):
if not _cfg.get('BW_img', False):
return
if event.sender.id in blacklist:
return
msg = "".join(map(str, event.message_chain[Plain]))
Expand All @@ -73,7 +79,8 @@ async def bwimg(event: GroupMessage):
await img.download(filename=f'./images/tempimg/{imgname}')
makebwimg(imgname, m.group(1))
# await bot.send(event, await messagechain_builder(imgpath=f'./images/ImgGenerator/{imgname}'))
await messagechain_sender(event=event,msg=await messagechain_builder(imgpath=f'./images/ImgGenerator/{imgname}'))
await messagechain_sender(event=event,
msg=await messagechain_builder(imgpath=f'./images/ImgGenerator/{imgname}'))
deletesource(imgname)
# except Exception as e:
# print(e)
Expand Down
5 changes: 5 additions & 0 deletions plugin/ImgGenerator/csgokill.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
from PIL import Image, ImageFont, ImageDraw
from mirai import GroupMessage, Plain, At
from core import bot, blacklist
from utils import read_file
from utils.MessageChainBuilder import messagechain_builder

__all__ = ['cskill']

from utils.MessageChainSender import messagechain_sender

_cfg = read_file(r'./config/ImgGenerator/config.yml')


async def jisha(user: str, target: str, headshot=None, penetrate=None):
"""
Expand Down Expand Up @@ -88,6 +91,8 @@ async def jisha(user: str, target: str, headshot=None, penetrate=None):

@bot.on(GroupMessage)
async def cskill(event: GroupMessage):
if not _cfg.get('CSGOKill', False):
return
if event.sender.id in blacklist:
return
msg = "".join(map(str, event.message_chain[Plain]))
Expand Down
13 changes: 13 additions & 0 deletions plugin/ImgGenerator/file_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os

from utils.cfg_loader import write_file

if not os.path.exists('./images/ImgGenerator'):
os.mkdir(f'./images/ImgGenerator')
if not os.path.exists(r'./config/ImgGenerator'):
os.mkdir(r'./config/ImgGenerator')

if not os.path.exists(r'./config/ImgGenerator/config.yml'):
cfg = {'HoldUpCard': True, 'HoldUp': True, 'Kiss': True, 'Arrest': True, 'SmallLove': True, 'Throw': True,
'Eat': True, 'BW_img': True, 'Marry': True, 'Screenshot': True, 'CSGOKill': True}
write_file(content=cfg, path=r'./config/ImgGenerator/config.yml')
Loading

0 comments on commit 5230d67

Please sign in to comment.