Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ImAmelie committed Jun 20, 2022
2 parents 20e2eac + ff47b03 commit ef84e48
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 184 deletions.
2 changes: 1 addition & 1 deletion EVEBot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# nonebot.load_plugins("src/plugins")

nonebot.load_plugin('src.plugins.tool') # 提供一些设置(写死在程序中)
nonebot.load_plugin('src.plugins.util') # 提供一些功能函数 依赖tool
nonebot.load_plugin('src.plugins.settings') # 提供一些设置(来自配置文件)
nonebot.load_plugin('src.plugins.util') # 提供一些功能函数,下列的所有插件都依赖util插件,util插件依赖于 tool settings
nonebot.load_plugin('src.plugins.bind')
nonebot.load_plugin('src.plugins.data')
nonebot.load_plugin('src.plugins.help')
Expand Down
4 changes: 2 additions & 2 deletions EVEBot/src/plugins/bind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def _(bot: Bot, event: Event):

if not (event.message_type == 'group' and event.group_id in group_ids) :
return
if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return
if not (str(event.user_id) in config.superusers) :
await bind_function.finish(message=Message(
Expand All @@ -56,7 +56,7 @@ async def _(bot: Bot, event: Event):

if not (event.message_type == 'group' and event.group_id in group_ids) :
return
if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return
if not (str(event.user_id) in config.superusers) :
await unbind_function.finish(message=Message(
Expand Down
8 changes: 4 additions & 4 deletions EVEBot/src/plugins/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def _(bot: Bot, event: Event):

if not (event.message_type == 'group' and event.group_id in group_ids) :
return
if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return
if str(event.user_id) not in config.superusers :
await load.finish(message=Message(
Expand Down Expand Up @@ -69,7 +69,7 @@ async def _(bot: Bot, event: Event):
if not (event.message_type == 'group' and event.group_id in group_ids) :
return

if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return

s = str(event.get_message()).split(' ', 1)[1].strip()
Expand All @@ -94,7 +94,7 @@ async def _(bot: Bot, event: Event):

if not (event.message_type == 'group' and event.group_id in group_ids) :
return
if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return

msg = '关键字列表:\n'
Expand All @@ -116,7 +116,7 @@ async def _(bot: Bot, event: Event):

for k, _ in content.items() :
if re.fullmatch('^(' + k + ')$', s) is not None :
if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return
msg = content[k]
await dot.finish(message=Message(msg))
Expand Down
4 changes: 2 additions & 2 deletions EVEBot/src/plugins/help/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async def _(bot: Bot, event: Event):
if not (event.message_type == 'group' and event.group_id in group_ids) :
return

if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return

await help.finish(
Expand Down Expand Up @@ -44,7 +44,7 @@ async def _(bot: Bot, event: Event):
async def _(bot: Bot, event: Event):
if not (event.message_type == 'group' and event.group_id in group_ids) :
return
if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return
await tools.finish(
'常用工具:\n'
Expand Down
2 changes: 1 addition & 1 deletion EVEBot/src/plugins/jita/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def _(bot: Bot, event: Event):
if not (event.message_type == 'group' and event.group_id in group_ids) :
return

if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return

name = str(event.get_message()).split(' ', 1)[1].strip()
Expand Down
22 changes: 13 additions & 9 deletions EVEBot/src/plugins/kb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

client = httpx.AsyncClient()

kb = on_regex(r'^[\.。](kb|zkb)\s*\S+')
kb = on_regex(r'^[\.。](kb|zkb) \s*\S+')
@kb.handle()
async def _(bot: Bot, event: Event):
if not (event.message_type == 'group' and event.group_id in group_ids) :
return
if await util.isPass() :
if await util.isPass() or await util.isBan(event.user_id) :
return
name = str(event.get_message()).split(' ', 1)[1].strip()
name_urlcode = urllib.parse.quote(name)
Expand Down Expand Up @@ -59,11 +59,13 @@ async def _(bot: Bot, event: Event):

msg = ''
msg = msg + f'[CQ:image,file=https://images.evetech.net/characters/{character_id}/portrait?size=128]' + '\n'
msg = msg + f'角色名: {name}\n'
if 'name' in zkb_json['info'] :
name = zkb_json['info']['name']
msg = msg + f'角色: {name}\n'

if 'birthday' in zkb_json['info'] :
birthday = zkb_json['info']['birthday'].split('T')[0]
msg = msg + f'创建日期: {birthday}\n'
msg = msg + f'生日: {birthday}\n'

if 'title' in zkb_json['info'] :
title = re.sub(r'<[^>]*>', '', zkb_json['info']['title'])
Expand All @@ -72,14 +74,11 @@ async def _(bot: Bot, event: Event):

corporation_str = None
alliance_str = None
count = len(zkb_json['topLists'])
i = 0
while i < count :
for i in range(len(zkb_json['topLists'])) :
if zkb_json['topLists'][i]['type'] == 'corporation' and len(zkb_json['topLists'][i]['values']) != 0 :
corporation_str = zkb_json['topLists'][i]['values'][0]['corporationName'] + ' [' + zkb_json['topLists'][i]['values'][0]['cticker'] + ']'
if zkb_json['topLists'][i]['type'] == 'alliance' and len(zkb_json['topLists'][i]['values']) != 0 :
alliance_str = zkb_json['topLists'][i]['values'][0]['allianceName'] + ' <' + zkb_json['topLists'][i]['values'][0]['aticker'] + '>'
i = i + 1
if corporation_str is None and 'corporationID' in zkb_json['info'] :
try:
corporation_re = await client.get(url=f"https://esi.evetech.net/latest/corporations/{zkb_json['info']['corporationID']}/?datasource=tranquility", headers=headers)
Expand Down Expand Up @@ -133,7 +132,12 @@ async def _(bot: Bot, event: Event):
else:
iskLost = 0
msg = msg + f'损失: {shipsLost} | 价值: {iskLost:,.0f}\n'
soloKills = zkb_json['soloKills']
shipsLost = 1 if shipsLost == 0 else shipsLost
msg = msg + f'KD: {shipsDestroyed / shipsLost:,.2f} | '
if 'soloKills' in zkb_json :
soloKills = zkb_json['soloKills']
else:
soloKills = 0
msg = msg + f'SOLO: {soloKills}\n'
msg = msg + f'https://zkillboard.com/character/{character_id}/'

Expand Down
Loading

0 comments on commit ef84e48

Please sign in to comment.