Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Oct 3, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -56 to +60
releaseDir(OlivaDiceCore.data.dataDirRoot + '/' + bot_hash)
releaseDir(OlivaDiceCore.data.dataDirRoot + '/' + bot_hash + '/console')
fileDir = OlivaDiceCore.data.dataDirRoot + '/' + bot_hash + '/console'
releaseDir(f'{OlivaDiceCore.data.dataDirRoot}/{bot_hash}')
releaseDir(f'{OlivaDiceCore.data.dataDirRoot}/{bot_hash}/console')
fileDir = f'{OlivaDiceCore.data.dataDirRoot}/{bot_hash}/console'
fileName = 'censor.json'
path = fileDir + '/' + fileName
path = f'{fileDir}/{fileName}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function readConfigListByHash refactored with the following changes:

Comment on lines -73 to +77
releaseDir(OlivaDiceCore.data.dataDirRoot + '/' + bot_hash)
releaseDir(OlivaDiceCore.data.dataDirRoot + '/' + bot_hash + '/console')
fileDir = OlivaDiceCore.data.dataDirRoot + '/' + bot_hash + '/console'
releaseDir(f'{OlivaDiceCore.data.dataDirRoot}/{bot_hash}')
releaseDir(f'{OlivaDiceCore.data.dataDirRoot}/{bot_hash}/console')
fileDir = f'{OlivaDiceCore.data.dataDirRoot}/{bot_hash}/console'
fileName = 'censor.json'
path = fileDir + '/' + fileName
path = f'{fileDir}/{fileName}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function writeConfigListByHash refactored with the following changes:

Comment on lines -97 to +103
res = []
if bot_hash in gCensorConfigList \
and 'censorList' in gCensorConfigList[bot_hash] \
and type(gCensorConfigList[bot_hash]['censorList']) is list:
res = gCensorConfigList[bot_hash]['censorList']
return res
return (
gCensorConfigList[bot_hash]['censorList']
if bot_hash in gCensorConfigList
and 'censorList' in gCensorConfigList[bot_hash]
and type(gCensorConfigList[bot_hash]['censorList']) is list
else []
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function getConfigList refactored with the following changes:

Comment on lines -122 to +125
releaseDir(OlivaDiceCore.data.dataDirRoot + '/unity')
releaseDir(OlivaDiceCore.data.dataDirRoot + '/unity/censor')
fileDir = OlivaDiceCore.data.dataDirRoot + '/unity/censor'
releaseDir(f'{OlivaDiceCore.data.dataDirRoot}/unity')
releaseDir(f'{OlivaDiceCore.data.dataDirRoot}/unity/censor')
fileDir = f'{OlivaDiceCore.data.dataDirRoot}/unity/censor'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function initCensor refactored with the following changes:

Comment on lines +89 to +95
consoleSwitchFile = 'switch.json'
for dictConsoleSwitch_this in dictConsoleSwitch:
botHash = dictConsoleSwitch_this
releaseDir(OlivaDiceCore.data.dataDirRoot + '/' + botHash)
releaseDir(OlivaDiceCore.data.dataDirRoot + '/' + botHash + '/console')
consoleSwitchDir = OlivaDiceCore.data.dataDirRoot + '/' + botHash + '/console'
consoleSwitchFile = 'switch.json'
consoleSwitchPath = consoleSwitchDir + '/' + consoleSwitchFile
releaseDir(f'{OlivaDiceCore.data.dataDirRoot}/{botHash}')
releaseDir(f'{OlivaDiceCore.data.dataDirRoot}/{botHash}/console')
consoleSwitchDir = f'{OlivaDiceCore.data.dataDirRoot}/{botHash}/console'
consoleSwitchPath = f'{consoleSwitchDir}/{consoleSwitchFile}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function saveConsoleSwitch refactored with the following changes:

Comment on lines -344 to +328
res = reg_res
return res
return reg_res
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function formatSTRReplace refactored with the following changes:

Comment on lines -21 to +22
def init(plugin_event, Proc):
OlivaDiceCore.msgReply.unity_init(plugin_event, Proc)
def init(self, Proc):
OlivaDiceCore.msgReply.unity_init(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.init refactored with the following changes:

Comment on lines -24 to +25
def init_after(plugin_event, Proc):
OlivaDiceCore.msgReply.unity_init_after(plugin_event, Proc)
def init_after(self, Proc):
OlivaDiceCore.msgReply.unity_init_after(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.init_after refactored with the following changes:

Comment on lines -27 to +28
def private_message(plugin_event, Proc):
OlivaDiceCore.msgReply.unity_reply(plugin_event, Proc)
def private_message(self, Proc):
OlivaDiceCore.msgReply.unity_reply(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.private_message refactored with the following changes:

Comment on lines -30 to +31
def group_message(plugin_event, Proc):
OlivaDiceCore.msgReply.unity_reply(plugin_event, Proc)
def group_message(self, Proc):
OlivaDiceCore.msgReply.unity_reply(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.group_message refactored with the following changes:

Comment on lines -33 to +34
def poke(plugin_event, Proc):
OlivaDiceCore.msgReply.poke_reply(plugin_event, Proc)
def poke(self, Proc):
OlivaDiceCore.msgReply.poke_reply(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.poke refactored with the following changes:

Comment on lines -36 to +37
def friend_add_request(plugin_event, Proc):
OlivaDiceCore.ordinaryInviteManager.unity_friend_add_request(plugin_event, Proc)
def friend_add_request(self, Proc):
OlivaDiceCore.ordinaryInviteManager.unity_friend_add_request(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.friend_add_request refactored with the following changes:

Comment on lines -39 to +40
def group_invite_request(plugin_event, Proc):
OlivaDiceCore.ordinaryInviteManager.unity_group_invite_request(plugin_event, Proc)
def group_invite_request(self, Proc):
OlivaDiceCore.ordinaryInviteManager.unity_group_invite_request(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.group_invite_request refactored with the following changes:

Comment on lines -42 to +43
def group_member_increase(plugin_event, Proc):
OlivaDiceCore.ordinaryInviteManager.unity_group_member_increase(plugin_event, Proc)
def group_member_increase(self, Proc):
OlivaDiceCore.ordinaryInviteManager.unity_group_member_increase(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.group_member_increase refactored with the following changes:

Comment on lines -45 to +46
def heartbeat(plugin_event, Proc):
OlivaDiceCore.pulse.unity_heartbeat(plugin_event, Proc)
def heartbeat(self, Proc):
OlivaDiceCore.pulse.unity_heartbeat(self, Proc)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Event.heartbeat refactored with the following changes:

Comment on lines -138 to -142
if tmp_set_para != None:
if tmp_set_para is None:
tmp_reply_str = OlivaDiceCore.msgCustomManager.formatReplySTR(dictStrCustom['strShowGroupMainDiceNone'], dictTValue)
else:
dictTValue['tResult'] = tmp_set_para
tmp_reply_str = OlivaDiceCore.msgCustomManager.formatReplySTR(dictStrCustom['strShowGroupMainDice'], dictTValue)
else:
tmp_reply_str = OlivaDiceCore.msgCustomManager.formatReplySTR(dictStrCustom['strShowGroupMainDiceNone'], dictTValue)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function replySET_command refactored with the following changes:

Comment on lines -238 to +243
if not flag_is_from_master and tmp_reast_str in ['debug']:
pass
else:
if flag_is_from_master or tmp_reast_str not in ['debug']:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function replyRR_command refactored with the following changes:

Comment on lines -288 to +326
res = dictStrCustom['strPcSkillCheckError']
if tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_SUCCESS:
res = dictStrCustom['strPcSkillCheckSucceed']
return dictStrCustom['strPcSkillCheckSucceed']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_HARD_SUCCESS:
res = dictStrCustom['strPcSkillCheckHardSucceed']
return dictStrCustom['strPcSkillCheckHardSucceed']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_EXTREME_HARD_SUCCESS:
res = dictStrCustom['strPcSkillCheckExtremeHardSucceed']
return dictStrCustom['strPcSkillCheckExtremeHardSucceed']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_GREAT_SUCCESS:
res = dictStrCustom['strPcSkillCheckGreatSucceed']
return dictStrCustom['strPcSkillCheckGreatSucceed']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FAIL:
res = dictStrCustom['strPcSkillCheckFailed']
return dictStrCustom['strPcSkillCheckFailed']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_GREAT_FAIL:
res = dictStrCustom['strPcSkillCheckGreatFailed']
return dictStrCustom['strPcSkillCheckGreatFailed']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_01:
res = dictStrCustom['strPcSkillCheckFate01']
return dictStrCustom['strPcSkillCheckFate01']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_02:
res = dictStrCustom['strPcSkillCheckFate02']
return dictStrCustom['strPcSkillCheckFate02']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_03:
res = dictStrCustom['strPcSkillCheckFate03']
return dictStrCustom['strPcSkillCheckFate03']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_04:
res = dictStrCustom['strPcSkillCheckFate04']
return dictStrCustom['strPcSkillCheckFate04']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_05:
res = dictStrCustom['strPcSkillCheckFate05']
return dictStrCustom['strPcSkillCheckFate05']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_06:
res = dictStrCustom['strPcSkillCheckFate06']
return dictStrCustom['strPcSkillCheckFate06']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_07:
res = dictStrCustom['strPcSkillCheckFate07']
return dictStrCustom['strPcSkillCheckFate07']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_08:
res = dictStrCustom['strPcSkillCheckFate08']
return dictStrCustom['strPcSkillCheckFate08']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_09:
res = dictStrCustom['strPcSkillCheckFate09']
return dictStrCustom['strPcSkillCheckFate09']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_10:
res = dictStrCustom['strPcSkillCheckFate10']
return dictStrCustom['strPcSkillCheckFate10']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_FATE_11:
res = dictStrCustom['strPcSkillCheckFate11']
return dictStrCustom['strPcSkillCheckFate11']
elif tmpSkillCheckType == OlivaDiceCore.skillCheck.resultType.SKILLCHECK_NOPE:
res = dictStrCustom['strPcSkillCheckNope']
return dictStrCustom['strPcSkillCheckNope']
else:
res = dictStrCustom['strPcSkillCheckError']
return res
return dictStrCustom['strPcSkillCheckError']
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_SkillCheckReasult refactored with the following changes:

if initList == None:
self.data = []
else:
self.data = initList
self.data = [] if initList is None else initList
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Stack.__init__ refactored with the following changes:

Comment on lines -175 to +172
if self.type == self.nodeType.NUMBER:
return True
else:
return False
return self.type == self.nodeType.NUMBER
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calNode.isNumber refactored with the following changes:

Comment on lines -181 to +175
if self.type == self.nodeType.OPERATION:
return True
else:
return False
return self.type == self.nodeType.OPERATION
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calNode.isOperation refactored with the following changes:

Comment on lines -187 to +178
if self.type == self.nodeType.TUPLE:
return True
else:
return False
return self.type == self.nodeType.TUPLE
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calNode.isTuple refactored with the following changes:

Comment on lines -209 to +197
if self.data.isdigit():
return int(self.data)
else:
return 0
return int(self.data) if self.data.isdigit() else 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calNumberNode.getInt refactored with the following changes:

Comment on lines -258 to +259
if self.data == '-':
if self.data == '$t':
self.valLeftDefault = 1
self.vals['='] = None
elif self.data == '-':
self.valStarterLeftDefault = 0
elif self.data == '?':
self.valRightDefault = 0
self.vals[':'] = None
elif self.data == 'a':
self.vals['k'] = 8
self.vals['q'] = None
self.vals['m'] = 10
elif self.data in ['b', 'p']:
self.valLeftDefault = 1
self.valRightDefault = 1
elif self.data == 'c':
self.vals['m'] = 10
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calOperationNode.initOperation refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Comment on lines -368 to +342
if self.resError == None:
if self.resError is None:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RD.roll refactored with the following changes:

Comment on lines -21 to +25
flag_enable_default = 1
flag_enable = 1
flag_enable = OlivaDiceCore.console.getConsoleSwitchByHash('autoAcceptGroupAdd', 'unity')
flag_enable = OlivaDiceCore.console.getConsoleSwitchByHash('autoAcceptGroupAdd', plugin_event.bot_info.hash)
if flag_enable == None:
if flag_enable is None:
flag_enable_default = 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unity_group_invite_request refactored with the following changes:

Comment on lines -53 to +57
flag_enable_default = 1
flag_enable = 1
flag_enable = OlivaDiceCore.console.getConsoleSwitchByHash('autoAcceptFriendAdd', 'unity')
flag_enable = OlivaDiceCore.console.getConsoleSwitchByHash('autoAcceptFriendAdd', plugin_event.bot_info.hash)
if flag_enable == None:
if flag_enable is None:
flag_enable_default = 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unity_friend_add_request refactored with the following changes:

Comment on lines -99 to +102
if fake_plugin_event.data.host_id != None:
tmp_hagID = '%s|%s' % (str(plugin_event.data.host_id), str(plugin_event.data.group_id))
else:
if fake_plugin_event.data.host_id is None:
tmp_hagID = str(plugin_event.data.group_id)
else:
tmp_hagID = f'{str(plugin_event.data.host_id)}|{str(plugin_event.data.group_id)}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unity_group_member_increase refactored with the following changes:

Comment on lines -59 to +65
releaseDir(dataDirRoot_this + '/unity')
releaseDir(dataDirRoot_this + '/unity/extend')
releaseDir(dataDirRoot_this + '/unity/extend/template')
dataDir = dataDirRoot_this + '/unity/extend/template'
releaseDir(f'{dataDirRoot_this}/unity')
releaseDir(f'{dataDirRoot_this}/unity/extend')
releaseDir(f'{dataDirRoot_this}/unity/extend/template')
dataDir = f'{dataDirRoot_this}/unity/extend/template'
dataPathList = os.listdir(dataDir)
for dataName in dataPathList:
dataPath = dataDir + '/' + dataName
dataPath = f'{dataDir}/{dataName}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dataPcCardTemplateDefaultInit refactored with the following changes:

This removes the following comments ( why? ):

# 此处等待后续实现特异化的补丁逻辑

Comment on lines -99 to +92
for dictPcCardData_hostkey_this in dictPcCardData[dictPcCardData_this]:
for _ in dictPcCardData[dictPcCardData_this]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dataPcCardTotalCount refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants