Skip to content

Commit

Permalink
初始化项目
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Nov 20, 2021
1 parent 8be639e commit ea46724
Show file tree
Hide file tree
Showing 8 changed files with 946 additions and 0 deletions.
661 changes: 661 additions & 0 deletions OlivaDiceJoy/LICENSE

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions OlivaDiceJoy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- encoding: utf-8 -*-
'''
_______________________ _________________________________________
__ __ \__ /____ _/_ | / /__ |__ __ \___ _/_ ____/__ ____/
_ / / /_ / __ / __ | / /__ /| |_ / / /__ / _ / __ __/
/ /_/ /_ /____/ / __ |/ / _ ___ | /_/ /__/ / / /___ _ /___
\____/ /_____/___/ _____/ /_/ |_/_____/ /___/ \____/ /_____/
@File : __init__.py
@Author : lunzhiPenxil仑质
@Contact : [email protected]
@License : AGPL
@Copyright : (C) 2020-2021, OlivOS-Team
@Desc : None
'''

import OlivaDiceCore
import OlivaDiceJoy.main
import OlivaDiceJoy.msgReply
import OlivaDiceJoy.msgCustom
import OlivaDiceJoy.msgCustomManager
14 changes: 14 additions & 0 deletions OlivaDiceJoy/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name" : "OlivaDice娱乐模块",
"author" : "lunzhiPenxil",
"namespace" : "OlivaDiceJoy",
"message_mode" : "old_string",
"priority" : 30010,
"support" : [
{
"sdk" : "all",
"platform" : "all",
"model" : "all"
}
]
}
32 changes: 32 additions & 0 deletions OlivaDiceJoy/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- encoding: utf-8 -*-
'''
_______________________ _________________________________________
__ __ \__ /____ _/_ | / /__ |__ __ \___ _/_ ____/__ ____/
_ / / /_ / __ / __ | / /__ /| |_ / / /__ / _ / __ __/
/ /_/ /_ /____/ / __ |/ / _ ___ | /_/ /__/ / / /___ _ /___
\____/ /_____/___/ _____/ /_/ |_/_____/ /___/ \____/ /_____/
@File : main.py
@Author : lunzhiPenxil仑质
@Contact : [email protected]
@License : AGPL
@Copyright : (C) 2020-2021, OlivOS-Team
@Desc : None
'''

import OlivOS
import OlivaDiceJoy
import OlivaDiceCore

class Event(object):
def init(plugin_event, Proc):
OlivaDiceJoy.msgReply.unity_init(plugin_event, Proc)

def private_message(plugin_event, Proc):
OlivaDiceJoy.msgReply.unity_reply(plugin_event, Proc)

def group_message(plugin_event, Proc):
OlivaDiceJoy.msgReply.unity_reply(plugin_event, Proc)

def poke(plugin_event, Proc):
pass
35 changes: 35 additions & 0 deletions OlivaDiceJoy/msgCustom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- encoding: utf-8 -*-
'''
_______________________ _________________________________________
__ __ \__ /____ _/_ | / /__ |__ __ \___ _/_ ____/__ ____/
_ / / /_ / __ / __ | / /__ /| |_ / / /__ / _ / __ __/
/ /_/ /_ /____/ / __ |/ / _ ___ | /_/ /__/ / / /___ _ /___
\____/ /_____/___/ _____/ /_/ |_/_____/ /___/ \____/ /_____/
@File : msgCustom.py
@Author : lunzhiPenxil仑质
@Contact : [email protected]
@License : AGPL
@Copyright : (C) 2020-2021, OlivOS-Team
@Desc : None
'''

import OlivOS
import OlivaDiceCore
import OlivaDiceJoy

dictStrCustomDict = {}

dictStrCustom = {
'strJoyJrrp': '[{tName}]的今日人品为[{tJrrpResult}]'
}

dictStrConst = {
}

dictGValue = {
}

dictTValue = {
'tJrrpResult': 'N/A'
}
33 changes: 33 additions & 0 deletions OlivaDiceJoy/msgCustomManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- encoding: utf-8 -*-
'''
_______________________ _________________________________________
__ __ \__ /____ _/_ | / /__ |__ __ \___ _/_ ____/__ ____/
_ / / /_ / __ / __ | / /__ /| |_ / / /__ / _ / __ __/
/ /_/ /_ /____/ / __ |/ / _ ___ | /_/ /__/ / / /___ _ /___
\____/ /_____/___/ _____/ /_/ |_/_____/ /___/ \____/ /_____/
@File : msgCustomManager.py
@Author : lunzhiPenxil仑质
@Contact : [email protected]
@License : AGPL
@Copyright : (C) 2020-2021, OlivOS-Team
@Desc : None
'''

import OlivOS
import OlivaDiceCore
import OlivaDiceJoy

import os
import json

def initMsgCustom(bot_info_dict):
for bot_info_dict_this in bot_info_dict:
if bot_info_dict_this not in OlivaDiceCore.msgCustom.dictStrCustomDict:
OlivaDiceCore.msgCustom.dictStrCustomDict[bot_info_dict_this] = {}
for dictStrCustom_this in OlivaDiceJoy.msgCustom.dictStrCustom:
if dictStrCustom_this not in OlivaDiceCore.msgCustom.dictStrCustomDict[bot_info_dict_this]:
OlivaDiceCore.msgCustom.dictStrCustomDict[bot_info_dict_this][dictStrCustom_this] = OlivaDiceJoy.msgCustom.dictStrCustom[dictStrCustom_this]
OlivaDiceCore.msgCustom.dictStrConst.update(OlivaDiceJoy.msgCustom.dictStrConst)
OlivaDiceCore.msgCustom.dictGValue.update(OlivaDiceJoy.msgCustom.dictGValue)
OlivaDiceCore.msgCustom.dictTValue.update(OlivaDiceJoy.msgCustom.dictTValue)
148 changes: 148 additions & 0 deletions OlivaDiceJoy/msgReply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# -*- encoding: utf-8 -*-
'''
_______________________ _________________________________________
__ __ \__ /____ _/_ | / /__ |__ __ \___ _/_ ____/__ ____/
_ / / /_ / __ / __ | / /__ /| |_ / / /__ / _ / __ __/
/ /_/ /_ /____/ / __ |/ / _ ___ | /_/ /__/ / / /___ _ /___
\____/ /_____/___/ _____/ /_/ |_/_____/ /___/ \____/ /_____/
@File : msgReply.py
@Author : lunzhiPenxil仑质
@Contact : [email protected]
@License : AGPL
@Copyright : (C) 2020-2021, OlivOS-Team
@Desc : None
'''

import OlivOS
import OlivaDiceJoy
import OlivaDiceCore

import hashlib

def unity_init(plugin_event, Proc):
data_init(plugin_event, Proc)

def data_init(plugin_event, Proc):
OlivaDiceJoy.msgCustomManager.initMsgCustom(Proc.Proc_data['bot_info_dict'])

def unity_reply(plugin_event, Proc):
data_init(plugin_event, Proc)
OlivaDiceCore.userConfig.setMsgCount()
dictTValue = OlivaDiceCore.msgCustom.dictTValue.copy()
dictTValue['tName'] = plugin_event.data.sender['nickname']
dictStrCustom = OlivaDiceCore.msgCustom.dictStrCustomDict[plugin_event.bot_info.hash]
dictGValue = OlivaDiceCore.msgCustom.dictGValue
dictTValue.update(dictGValue)

replyMsg = OlivaDiceCore.msgReply.replyMsg
isMatchWordStart = OlivaDiceCore.msgReply.isMatchWordStart
getMatchWordStartRight = OlivaDiceCore.msgReply.getMatchWordStartRight
skipSpaceStart = OlivaDiceCore.msgReply.skipSpaceStart
skipToRight = OlivaDiceCore.msgReply.skipToRight

tmp_at_str = OlivOS.messageAPI.PARA.at(plugin_event.base_info['self_id']).CQ()
tmp_at_str_sub = None
if 'sub_self_id' in plugin_event.data.extend:
if plugin_event.data.extend['sub_self_id'] != None:
tmp_at_str_sub = OlivOS.messageAPI.PARA.at(plugin_event.data.extend['sub_self_id']).CQ()
tmp_command_str_1 = '.'
tmp_command_str_2 = '。'
tmp_command_str_3 = '/'
tmp_reast_str = plugin_event.data.message
flag_force_reply = False
flag_is_command = False
flag_is_from_host = False
flag_is_from_group = False
flag_is_from_group_admin = False
flag_is_from_group_have_admin = False
flag_is_from_master = False
if isMatchWordStart(tmp_reast_str, '[CQ:reply,id='):
tmp_reast_str = skipToRight(tmp_reast_str, ']')
tmp_reast_str = tmp_reast_str[1:]
if isMatchWordStart(tmp_reast_str, tmp_at_str):
tmp_reast_str = getMatchWordStartRight(tmp_reast_str, tmp_at_str)
tmp_reast_str = skipSpaceStart(tmp_reast_str)
flag_force_reply = True
if isMatchWordStart(tmp_reast_str, tmp_at_str):
tmp_reast_str = getMatchWordStartRight(tmp_reast_str, tmp_at_str)
tmp_reast_str = skipSpaceStart(tmp_reast_str)
flag_force_reply = True
if tmp_at_str_sub != None:
if isMatchWordStart(tmp_reast_str, tmp_at_str_sub):
tmp_reast_str = getMatchWordStartRight(tmp_reast_str, tmp_at_str_sub)
tmp_reast_str = skipSpaceStart(tmp_reast_str)
flag_force_reply = True
if isMatchWordStart(tmp_reast_str, tmp_command_str_1):
tmp_reast_str = getMatchWordStartRight(tmp_reast_str, tmp_command_str_1)
flag_is_command = True
elif isMatchWordStart(tmp_reast_str, tmp_command_str_2):
tmp_reast_str = getMatchWordStartRight(tmp_reast_str, tmp_command_str_2)
flag_is_command = True
elif isMatchWordStart(tmp_reast_str, tmp_command_str_3):
tmp_reast_str = getMatchWordStartRight(tmp_reast_str, tmp_command_str_3)
flag_is_command = True
if flag_is_command:
if plugin_event.plugin_info['func_type'] == 'group_message':
if plugin_event.data.host_id != None:
flag_is_from_host = True
flag_is_from_group = True
elif plugin_event.plugin_info['func_type'] == 'private_message':
flag_is_from_group = False
if flag_is_from_group:
if 'role' in plugin_event.data.sender:
flag_is_from_group_have_admin = True
if plugin_event.data.sender['role'] in ['owner', 'admin']:
flag_is_from_group_admin = True
flag_hostEnable = True
if flag_is_from_host:
flag_hostEnable = OlivaDiceCore.userConfig.getUserConfigByKey(
userId = plugin_event.data.host_id,
userType = 'host',
platform = plugin_event.platform['platform'],
userConfigKey = 'hostEnable',
botHash = plugin_event.bot_info.hash
)
flag_groupEnable = True
if flag_is_from_group:
if flag_is_from_host:
if flag_hostEnable:
flag_groupEnable = OlivaDiceCore.userConfig.getUserConfigByKey(
userId = plugin_event.data.group_id,
userType = 'group',
platform = plugin_event.platform['platform'],
userConfigKey = 'groupEnable',
botHash = plugin_event.bot_info.hash
)
else:
flag_groupEnable = OlivaDiceCore.userConfig.getUserConfigByKey(
userId = plugin_event.data.group_id,
userType = 'group',
platform = plugin_event.platform['platform'],
userConfigKey = 'groupWithHostEnable',
botHash = plugin_event.bot_info.hash
)
else:
flag_groupEnable = OlivaDiceCore.userConfig.getUserConfigByKey(
userId = plugin_event.data.group_id,
userType = 'group',
platform = plugin_event.platform['platform'],
userConfigKey = 'groupEnable',
botHash = plugin_event.bot_info.hash
)
#此群关闭时中断处理
if not flag_groupEnable and not flag_force_reply:
return
if isMatchWordStart(tmp_reast_str, 'jrrp'):
tmp_reast_str = getMatchWordStartRight(tmp_reast_str, 'jrrp')
tmp_reast_str = skipSpaceStart(tmp_reast_str)
tmp_reast_str = tmp_reast_str.rstrip(' ')
tmp_reply_str = None
hash_tmp = hashlib.new('md5')
hash_tmp.update(str(plugin_event.data.user_id).encode(encoding='UTF-8'))
tmp_jrrp_int = int(int(hash_tmp.hexdigest(), 16) % 100) + 1
dictTValue['tJrrpResult'] = str(tmp_jrrp_int)
tmp_reply_str = dictStrCustom['strJoyJrrp'].format(**dictTValue)
if tmp_reply_str != None:
replyMsg(plugin_event, tmp_reply_str)
return
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# OlivaDiceJoy
Make fun, not war.

此项目为 `青果核心掷骰机器人` `V3.0` 以上版本 `娱乐模块` 项目仓库

0 comments on commit ea46724

Please sign in to comment.