Skip to content

Commit

Permalink
update style issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DoroWolf committed Dec 14, 2024
1 parent 1ab73ca commit 70e629a
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 44 deletions.
21 changes: 10 additions & 11 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,17 @@ def restart_process(bot_name: str):
for p in processes:
if p.is_alive():
continue
if p.exitcode == 233:
Logger.warning(f'{p.pid} ({p.name}) exited with code 233, restart all bots.')
raise RestartBot
else:
if p.exitcode == 233:
Logger.warning(f'{p.pid} ({p.name}) exited with code 233, restart all bots.')
raise RestartBot
else:
Logger.critical(f'Process {p.pid} ({p.name}) exited with code {p.exitcode}, please check the log.')
processes.remove(p)
p.terminate()
p.join()
p.close()
restart_process(p.name)
break
Logger.critical(f'Process {p.pid} ({p.name}) exited with code {p.exitcode}, please check the log.')
processes.remove(p)
p.terminate()
p.join()
p.close()
restart_process(p.name)
break

if not processes:
break
Expand Down
2 changes: 1 addition & 1 deletion bots/aiocqhttp/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
target_guild_prefix = f'{client_name}|Guild'
target_group_prefix = f'{client_name}|Group'
target_private_prefix = f'{client_name}|Private'
target_prefix_list = [target_guild_prefix, target_group_prefix, target_private_prefix]
target_prefix_list = [target_guild_prefix, target_group_prefix, target_private_prefix]
6 changes: 5 additions & 1 deletion bots/aiogram/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
sender_prefix_list = [sender_prefix]

target_prefix = client_name
target_prefix_list = [f'{client_name}|Private', f'{client_name}|Group', f'{client_name}|Supergroup', f'{client_name}|Channel']
target_prefix_list = [
f'{client_name}|Private',
f'{client_name}|Group',
f'{client_name}|Supergroup',
f'{client_name}|Channel']
2 changes: 1 addition & 1 deletion bots/discord/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
target_channel_prefix = f'{client_name}|Channel'
target_dm_channel_prefix = f'{client_name}|DM|Channel'
target_slash_prefix = f'{client_name}|Slash'
target_prefix_list = [target_channel_prefix, target_dm_channel_prefix]
target_prefix_list = [target_channel_prefix, target_dm_channel_prefix]
2 changes: 1 addition & 1 deletion bots/kook/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
target_prefix = client_name
target_group_prefix = f'{client_name}|Group'
target_person_prefix = f'{client_name}|Person'
target_prefix_list = [target_group_prefix, target_person_prefix]
target_prefix_list = [target_group_prefix, target_person_prefix]
2 changes: 1 addition & 1 deletion bots/matrix/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
sender_prefix_list = [sender_prefix]

target_prefix = f'{client_name}|Room'
target_prefix_list = [target_prefix]
target_prefix_list = [target_prefix]
2 changes: 1 addition & 1 deletion core/console/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
sender_prefix_list = [sender_prefix]

target_prefix = f'{client_name}|Console'
target_prefix_list = [target_prefix]
target_prefix_list = [target_prefix]
3 changes: 1 addition & 2 deletions core/scripts/config_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def generate_config(dir_path, language):
if isint(lang) and (langI := (int(lang) - 1)) in range(len(lang_list)):
lang = list(lang_list.keys())[langI]
break
else:
print('Invalid input, please try again.')
print('Invalid input, please try again.')

generate_config(config_path, lang)

Expand Down
2 changes: 1 addition & 1 deletion modules/ask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def _(msg: Bot.MessageSession):
)
if run.status == 'completed':
break
elif run.status == 'failed':
if run.status == 'failed':
if run.last_error.code == 'rate_limit_exceeded' and \
'quota' not in run.last_error.message:
Logger.warning(run.last_error.json())
Expand Down
2 changes: 1 addition & 1 deletion modules/core/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async def help_generator(msg: Bot.MessageSession,
continue
if value.rss and not msg.Feature.rss:
continue
elif not is_superuser and value.required_superuser or \
if not is_superuser and value.required_superuser or \
not is_base_superuser and value.required_base_superuser:
continue

Expand Down
2 changes: 1 addition & 1 deletion modules/dice/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def parse_dice_expression(msg: Bot.MessageSession, dices: str):
try:
if any(item.lower() == func for func in math_funcs):
continue
elif 'A' in item:
if 'A' in item:
dice_count += 1
dice_expr_list[j] = WODDice(msg, item)
elif 'C' in item:
Expand Down
5 changes: 2 additions & 3 deletions modules/maimai/libraries/maimaidx_apidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ async def update_cover() -> bool:
if Config('debug', False):
Logger.error(f'Failed to download {id}.png')
continue
else:
Logger.error(traceback.format_exc())
return False
Logger.error(traceback.format_exc())
return False
return True


Expand Down
12 changes: 6 additions & 6 deletions modules/maimai/maimai.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,12 @@ async def _(msg: Bot.MessageSession, diff: str, sid: str, score: float):
reduce = 101 - score # 理论值与给定完成率的差,以百分比计
if reduce <= 0 or reduce >= 101:
raise ValueError
tap_great = "{:.2f}".format(total_score * reduce / 10000) # 一个 TAP GREAT 减少 100 分
tap_great_prop = "{:.4f}".format(10000 / total_score)
b2t_2550_great = "{:.3f}".format(break_2550_reduce / 100) # 一个 TAP GREAT 减少 100 分
b2t_2550_great_prop = "{:.4f}".format(break_2550_reduce / total_score * 100)
b2t_2000_great = "{:.3f}".format(break_2000_reduce / 100) # 一个 TAP GREAT 减少 100 分
b2t_2000_great_prop = "{:.4f}".format(break_2000_reduce / total_score * 100)
tap_great = f"{(total_score * reduce / 10000):.2f}" # 一个 TAP GREAT 减少 100 分
tap_great_prop = f"{(10000 / total_score):.4f}"
b2t_2550_great = f"{(break_2550_reduce / 100):.3f}" # 一个 TAP GREAT 减少 100 分
b2t_2550_great_prop = f"{(break_2550_reduce / total_score * 100):.4f}"
b2t_2000_great = f"{(break_2000_reduce / 100):.3f}" # 一个 TAP GREAT 减少 100 分
b2t_2000_great_prop = f"{(break_2000_reduce / total_score * 100):.4f}"
await msg.finish(f'''{music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diff_list[diff_index]}
{msg.locale.t('maimai.message.scoreline',
scoreline=score,
Expand Down
10 changes: 5 additions & 5 deletions modules/mcv/mcv.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def mcv(msg: Bot.MessageSession):
snapshot=data['latest']['snapshot'],
release_time=msg.ts2strftime(time_release),
snapshot_time=msg.ts2strftime(time_snapshot))
except (ConnectionError, OSError): # Probably...
except ConnectionError: # Probably...
message1 = msg.locale.t("mcv.message.mcv.launcher.failed")
try:
mojira = json.loads(await get_url('https://bugs.mojang.com/rest/api/2/project/10400/versions', 200))
Expand Down Expand Up @@ -64,7 +64,7 @@ async def mcbv(msg: Bot.MessageSession):
pass
try:
data = json.loads(await get_url('https://bugs.mojang.com/rest/api/2/project/10200/versions', 200))
except (ConnectionError, OSError): # Probably...
except ConnectionError: # Probably...
return ErrorMessage('{mcv.message.error.server}', locale=msg.locale.locale, enable_report=False)
beta = []
preview = []
Expand Down Expand Up @@ -93,7 +93,7 @@ async def mcbv(msg: Bot.MessageSession):
async def mcdv(msg: Bot.MessageSession):
try:
data = json.loads(await get_url('https://bugs.mojang.com/rest/api/2/project/11901/versions', 200))
except (ConnectionError, OSError): # Probably...
except ConnectionError: # Probably...
return ErrorMessage('{mcv.message.error.server}', locale=msg.locale.locale, enable_report=False)
release = []
for v in data:
Expand All @@ -108,15 +108,15 @@ async def mcev(msg: Bot.MessageSession):
Logger.debug(data)
version = re.search(r'(?<=\[)(.*?)(?=])', data)[0]
Logger.debug(version)
except (ConnectionError, OSError): # Probably...
except ConnectionError: # Probably...
return ErrorMessage('{mcv.message.error.server}', locale=msg.locale.locale, enable_report=False)
return msg.locale.t("mcv.message.mcev", version=version)


async def mclgv(msg: Bot.MessageSession):
try:
data = json.loads(await get_url('https://bugs.mojang.com/rest/api/2/project/12200/versions', 200))
except (ConnectionError, OSError): # Probably...
except ConnectionError: # Probably...
return ErrorMessage('{mcv.message.error.server}', locale=msg.locale.locale, enable_report=False)
release = []
for v in data:
Expand Down
2 changes: 1 addition & 1 deletion modules/oba/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def size_convert(value):
size = 1024.0
for _, unit in enumerate(units):
if (value / size) < 1:
return '%.2f%s' % (value, ' ' + unit)
return f'{value:.2f} {unit}'
value /= size


Expand Down
2 changes: 1 addition & 1 deletion modules/summary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def _(msg: Bot.MessageSession):
if await check_bool(''.join(texts)):
await msg.finish(rickroll(msg))

char_count = sum([len(i) for i in texts])
char_count = sum(len(i) for i in texts)
wait_msg = await msg.send_message(
msg.locale.t('summary.message.waiting', count=char_count, time=round(char_count / 33.5, 1)))

Expand Down
8 changes: 4 additions & 4 deletions modules/twenty_four/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@ async def find_solution(numbers):

for perm in perms:
for expr in exprs: # 穷举就完事了
exp = '(({}{}{}){}{}){}{}'.format(perm[0], expr[0], perm[1], expr[1], perm[2], expr[2], perm[3])
exp = f'(({perm[0]}{expr[0]}{perm[1]}){expr[1]}{perm[2]}){expr[2]}{perm[3]}'
try:
if (calc(exp) == 24 or 0 < 24 - calc(exp) < 1e-13):
return exp
except BaseException:
pass
exp = '({}{}{}){}({}{}{})'.format(perm[0], expr[0], perm[1], expr[1], perm[2], expr[2], perm[3])
exp = f'({perm[0]}{expr[0]}{perm[1]}){expr[1]}({perm[2]}{expr[2]}{perm[3]})'
try:
if (calc(exp) == 24 or 0 < 24 - calc(exp) < 1e-13):
return exp
except BaseException:
pass
exp = '{}{}({}{}({}{}{}))'.format(perm[0], expr[0], perm[1], expr[1], perm[2], expr[2], perm[3])
exp = f'{perm[0]}{expr[0]}({perm[1]}{expr[1]}({perm[2]}{expr[2]}{perm[3]}))'
try:
if (calc(exp) == 24 or 0 < 24 - calc(exp) < 1e-13):
return exp
except BaseException:
pass
exp = '{}{}({}{}{}){}{}'.format(perm[0], expr[0], perm[1], expr[1], perm[2], expr[2], perm[3])
exp = f'{perm[0]}{expr[0]}({perm[1]}{expr[1]}{perm[2]}){expr[2]}{perm[3]}'
try:
if (calc(exp) == 24 or 0 < 24 - calc(exp) < 1e-13):
return exp
Expand Down
2 changes: 1 addition & 1 deletion modules/wiki/utils/ab.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from core.builtins import Url, Bot
from core.dirty_check import check
from modules.wiki.utils.time import strptime2ts
from modules.wiki.utils.wikilib import WikiLib, WikiInfo
from modules.wiki.utils.wikilib import WikiLib

AB_LIMIT = 5

Expand Down
2 changes: 1 addition & 1 deletion modules/wiki/utils/wikilib.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async def check_wiki_available(self):
api_match = self.url.split('//')[0] + api_match
# Logger.info(api_match)
wiki_api_link = api_match
except (TimeoutError, asyncio.TimeoutError):
except TimeoutError:
return WikiStatus(available=False, value=False, message=self.locale.t(
"wiki.message.utils.wikilib.get_failed.timeout"))
except IndexError:
Expand Down

0 comments on commit 70e629a

Please sign in to comment.