Skip to content

Commit

Permalink
Bug fixes and cleanup (#450)
Browse files Browse the repository at this point in the history
* chore: fix formatting

* chore: remove outdated database.sql

* fix: add aiomysql to requirements.txt

* fix: syntax error in minecraft cog

* chore: update example config

* fix: add missing munmute_help string

* fix: syntax warnings

* fix: silence aiomysql warnings

* fix: await close of aiohttp session

* chore: remove unnecssary diff

* chore: use original import order

* chore: remove aiomysql

* chore: change example `DATABASE` to postgres
  • Loading branch information
hampuskraft authored Nov 1, 2022
1 parent 7ea4a6c commit 0a870a4
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 293 deletions.
7 changes: 4 additions & 3 deletions GearBot/Cogs/Minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def get_info(self, ctx, project_name, log):
async def fetch_info(self, project_name):
session: aiohttp.ClientSession = self.bot.aiosession
async with session.get(f"https://api.cfwidget.com/mc-mods/minecraft/{project_name}") as reply:
if reply.status is 200: # all good, we can parse it
if reply.status == 200: # all good, we can parse it
parsed = json.loads(await reply.text())
p_type = parsed["type"]
info = {
Expand Down Expand Up @@ -91,13 +91,13 @@ async def fetch_info(self, project_name):
info["versions"] = map
return info

elif reply.status is 202: # New project, wait for the api to fetch it
elif reply.status == 202: # New project, wait for the api to fetch it
GearbotLogging.info(f"Info for {project_name} not available yet, trying again in 10 seconds.")
await asyncio.sleep(10)
return await self.fetch_info(project_name)
elif reply.status in (400, 404):
return None
elif reply.status is 500:
elif reply.status == 500:
GearbotLogging.error(f"Fetching info for {project_name} failed.")
return False
else:
Expand Down Expand Up @@ -128,6 +128,7 @@ async def cf(self, ctx):
pass

async def info(self, ctx, project_name: str):
pass

# @cf.command()
# async def latest(self, ctx, project_name: str, version: str):
Expand Down
2 changes: 1 addition & 1 deletion GearBot/Util/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def cleanExit(bot, trigger):
await GearbotLogging.bot_log(f"Shutdown triggered by {trigger}.")
await bot.logout()
await bot.close()
bot.aiosession.close()
await bot.aiosession.close()


def trim_message(message, limit):
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Gearbot


141 changes: 67 additions & 74 deletions config/master.json.example
Original file line number Diff line number Diff line change
@@ -1,76 +1,69 @@
{
"LOGIN_TOKEN": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"BOT_LOG_CHANNEL": 365908831328403456,
"CROWDIN_KEY": null,
"DATABASE_HOST": "localhost",
"DATABASE_NAME": "gearbot",
"DATABASE_PASS": "database password",
"DATABASE_PORT": 3306,
"DATABASE_USER": "gearbot",
"APEX_KEY": "",
"REDIS_HOST": "localhost",
"REDIS_PORT": 6379,
"REDIS_SOCKET": "",
"SENTRY_DSN": "",
"EMOJI": {
},
"EMOJI_GUILD": null,
"GUIDES": 0,
"inbox": 0,
"COGS": [
"Basic",
"Admin",
"Moderation",
"ServerAdmin",
"ModLog",
"CustCommands",
"BCVersionChecker",
"Reload",
"ReactionHandler",
"Censor",
"Infractions",
"Interactions",
"Minecraft",
"DMMessages",
"Reminders",
"Emoji",
"AntiSpam"
],
"TRANSLATIONS": {
"CHANNEL": 0,
"KEY": "",
"LOGIN": "",
"SOURCE": "DISABLED",
"WEBROOT": ""
},
"DOCS": true,
"DISABLED_COMMANDS": [],
"DASH_OUTAGE": {
"outage_detection": false,
"max_bot_outage_warnings": 1,
"dash_outage_channel": 999999999,
"dash_outage_pinged_roles": [],
"dash_outage_message": "The Dashboard went down! Please look into it!",
"dash_outage_embed": {
"title": "Dashboard Outage Detected",
"timestamp": "",
"color": "FF0000",
"description": "The Dashboard is suspected to be down, it hasn't responded in over 3 minutes!",
"author": {
"name": "Gearbot Dashboard Monitor"
},
"fields": [
{
"name": "Alert Count",
"value": "{warnings_sent}/{MAX_BOT_OUTAGE_WARNINGS}",
"inline": true
}
]
}
},
"global_inf_counter": true,
"min_cached_users": 0,
"purge_db": true

"LOGIN_TOKEN": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"BOT_LOG_CHANNEL": 365908831328403456,
"CROWDIN_KEY": null,
"DATABASE": "postgres://gearbot:gearbot@localhost:5432/gearbot",
"APEX_KEY": "",
"REDIS_HOST": "localhost",
"REDIS_PORT": 6379,
"REDIS_SOCKET": "",
"SENTRY_DSN": "",
"EMOJI": {},
"EMOJI_GUILD": 365498559174410241,
"GUIDES": 0,
"inbox": 0,
"COGS": [
"Basic",
"Admin",
"Moderation",
"ServerAdmin",
"ModLog",
"CustCommands",
"BCVersionChecker",
"Reload",
"ReactionHandler",
"Censor",
"Infractions",
"Interactions",
"Minecraft",
"DMMessages",
"Reminders",
"Emoji",
"AntiSpam"
],
"TRANSLATIONS": {
"CHANNEL": 0,
"KEY": "",
"LOGIN": "",
"SOURCE": "DISABLED",
"WEBROOT": ""
},
"DOCS": true,
"DISABLED_COMMANDS": [],
"DASH_OUTAGE": {
"outage_detection": false,
"max_bot_outage_warnings": 1,
"dash_outage_channel": 999999999,
"dash_outage_pinged_roles": [],
"dash_outage_message": "The Dashboard went down! Please look into it!",
"dash_outage_embed": {
"title": "Dashboard Outage Detected",
"timestamp": "",
"color": "FF0000",
"description": "The Dashboard is suspected to be down, it hasn't responded in over 3 minutes!",
"author": {
"name": "Gearbot Dashboard Monitor"
},
"fields": [
{
"name": "Alert Count",
"value": "{warnings_sent}/{MAX_BOT_OUTAGE_WARNINGS}",
"inline": true
}
]
}
},
"global_inf_counter": true,
"min_cached_users": 0,
"purge_db": true
}

76 changes: 0 additions & 76 deletions database.sql

This file was deleted.

5 changes: 1 addition & 4 deletions lang/bot.json
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{


}
{}
Loading

0 comments on commit 0a870a4

Please sign in to comment.