forked from Teahouse-Studios/akari-bot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Teahouse-Studios:master' into master
- Loading branch information
Showing
19 changed files
with
59 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,28 @@ | ||
import traceback | ||
|
||
from core.builtins import Bot, Url | ||
from core.dirty_check import rickroll | ||
from core.logger import Logger | ||
from core.utils.http import get_url | ||
from modules.github.utils import dirty_check, darkCheck | ||
|
||
|
||
async def search(msg: Bot.MessageSession, keyword: str): | ||
try: | ||
result = await get_url('https://api.github.com/search/repositories?q=' + keyword, 200, | ||
fmt='json') | ||
if result['total_count'] == 0: | ||
message = msg.locale.t("github.message.search.not_found") | ||
else: | ||
items = result['items'] | ||
items_out = [] | ||
for item in items: | ||
try: | ||
items_out.append(str(item['full_name'] + ': ' + str(Url(item['html_url'])))) | ||
except TypeError: | ||
continue | ||
message = msg.locale.t("github.message.search") + '\n' + '\n'.join(items_out[0:5]) | ||
if result['total_count'] > 5: | ||
message += '\n' + msg.locale.t("message.collapse", amount="5") | ||
result = await get_url('https://api.github.com/search/repositories?q=' + keyword, 200, | ||
fmt='json') | ||
if result['total_count'] == 0: | ||
message = msg.locale.t("github.message.search.not_found") | ||
else: | ||
items = result['items'] | ||
items_out = [] | ||
for item in items: | ||
try: | ||
items_out.append(str(item['full_name'] + ': ' + str(Url(item['html_url'])))) | ||
except TypeError: | ||
continue | ||
message = msg.locale.t("github.message.search") + '\n' + '\n'.join(items_out[0:5]) | ||
if result['total_count'] > 5: | ||
message += '\n' + msg.locale.t("message.collapse", amount="5") | ||
|
||
is_dirty = await dirty_check(message) or darkCheck(message) | ||
if is_dirty: | ||
await msg.finish(rickroll(msg)) | ||
is_dirty = await dirty_check(message) or darkCheck(message) | ||
if is_dirty: | ||
await msg.finish(rickroll(msg)) | ||
|
||
await msg.finish(message) | ||
except BaseException: | ||
Logger.error(traceback.format_exc()) | ||
await msg.finish(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters