Skip to content

Commit

Permalink
pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
DoroWolf committed Oct 3, 2024
1 parent 6b68d50 commit 7d00b36
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 2,717 deletions.
1 change: 1 addition & 0 deletions modules/github/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

SEARCH_LIMIT = 5


async def search(msg: Bot.MessageSession, keyword: str):
result = await get_url('https://api.github.com/search/repositories?q=' + keyword, 200,
fmt='json')
Expand Down
6 changes: 5 additions & 1 deletion modules/idlist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ async def _(msg: Bot.MessageSession, query: str):
v = x["value"].split('\n')[0]
plain_texts.append(f'{x["enumName"]}{x["key"]} -> {v}')
if resp['data']['count'] > SEARCH_LIMIT:
plain_texts.append(msg.locale.t('message.collapse', amount=SEARCH_LIMIT) + msg.locale.t('idlist.message.collapse'))
plain_texts.append(
msg.locale.t(
'message.collapse',
amount=SEARCH_LIMIT) +
msg.locale.t('idlist.message.collapse'))
plain_texts.append('https://ca.projectxero.top/idlist/' + resp['data']['hash'])
await msg.finish(plain_texts)
else:
Expand Down
53 changes: 32 additions & 21 deletions modules/oba/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def latest_version():
except Exception:
return None


def search_cluster(clusterList: dict, key: str, value: str):
result = []
regex = re.compile(value, re.IGNORECASE)
Expand Down Expand Up @@ -55,16 +56,21 @@ async def status(msg: Bot.MessageSession):
version = await latest_version()

msg_list = [msg.locale.t('oba.message.status.detail',
current_nodes=current_nodes,
load=load,
bandwidth=bandwidth,
current_bandwidth=current_bandwidth,
hits=hits,
size=size
)]
current_nodes=current_nodes,
load=load,
bandwidth=bandwidth,
current_bandwidth=current_bandwidth,
hits=hits,
size=size
)]
if version:
msg_list.append(msg.locale.t('oba.message.status.version', version=version))
msg_list.append(msg.locale.t('oba.message.query_time', query_time=msg.ts2strftime(datetime.now().timestamp(), timezone=False)))
msg_list.append(
msg.locale.t(
'oba.message.query_time',
query_time=msg.ts2strftime(
datetime.now().timestamp(),
timezone=False)))
await msg.finish(msg_list)


Expand All @@ -79,7 +85,12 @@ async def rank(msg: Bot.MessageSession, rank: int = 1):
size = size_convert(node.get('metric').get('bytes'))

msg_list = [status, msg.locale.t('oba.message.node', name=name, id=_id, hits=hits, size=size)]
msg_list.append(msg.locale.t('oba.message.query_time', query_time=msg.ts2strftime(datetime.now().timestamp(), timezone=False)))
msg_list.append(
msg.locale.t(
'oba.message.query_time',
query_time=msg.ts2strftime(
datetime.now().timestamp(),
timezone=False)))

if 'sponsor' not in node:
await msg.finish(msg_list)
Expand Down Expand Up @@ -119,12 +130,12 @@ async def top(msg: Bot.MessageSession, rank: int = 1):
hits = node.get('metric').get('hits')
size = size_convert(node.get('metric').get('bytes'))
node_list.append(f"{status} | {msg.locale.t('oba.message.top',
rank=i + 1,
name=name,
id=_id,
hits=hits,
size=size,
sponsor_name=sponsor_name)}")
rank=i + 1,
name=name,
id=_id,
hits=hits,
size=size,
sponsor_name=sponsor_name)}")
except KeyError:
break

Expand Down Expand Up @@ -153,12 +164,12 @@ async def search(msg: Bot.MessageSession, keyword: str):
hits = node.get('metric').get('hits')
size = size_convert(node.get('metric').get('bytes'))
node_list.append(f"{status} | {msg.locale.t('oba.message.top',
rank=rank,
name=name,
id=_id,
hits=hits,
size=size,
sponsor_name=sponsor_name)}")
rank=rank,
name=name,
id=_id,
hits=hits,
size=size,
sponsor_name=sponsor_name)}")
except KeyError:
break

Expand Down
1 change: 1 addition & 0 deletions modules/wiki/utils/ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

AB_LIMIT = 5


async def ab(msg: Bot.MessageSession, wiki_url):
wiki = WikiLib(wiki_url)
query = await wiki.get_json(action='query', list='abuselog', aflprop='user|title|action|result|filter|timestamp',
Expand Down
1 change: 1 addition & 0 deletions modules/wiki/utils/newbie.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

NEWBIE_LIMIT = 10


async def newbie(msg: Bot.MessageSession, wiki_url):
wiki = WikiLib(wiki_url)
query = await wiki.get_json(action='query', list='logevents', letype='newusers')
Expand Down
1 change: 1 addition & 0 deletions modules/wiki/utils/rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

RC_LIMIT = 10


async def rc(msg: Bot.MessageSession, wiki_url):
wiki = WikiLib(wiki_url)
query = await wiki.get_json(action='query', list='recentchanges',
Expand Down
Loading

0 comments on commit 7d00b36

Please sign in to comment.