diff --git a/setup.cfg b/setup.cfg index 7a587d0..6910a71 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,6 +23,7 @@ install_requires = humanize>=2.6.0 jishaku>=1.19.1.200 psutil>=5.7.2 + requests>=2.25.1 rich>=6.0.0 structured_config>=4.12 tortoise-orm>=0.16.17 diff --git a/tuxbot/cogs/Custom/functions/converters.py b/tuxbot/cogs/Custom/functions/converters.py index 6e1cd86..328fa15 100644 --- a/tuxbot/cogs/Custom/functions/converters.py +++ b/tuxbot/cogs/Custom/functions/converters.py @@ -2,7 +2,7 @@ from discord.ext import commands from jishaku.models import copy_context_with -_ = lambda x: x +def _(x): return x class AliasConvertor(commands.Converter): diff --git a/tuxbot/cogs/Polls/functions/converters.py b/tuxbot/cogs/Polls/functions/converters.py index 235627a..3b2cbcc 100644 --- a/tuxbot/cogs/Polls/functions/converters.py +++ b/tuxbot/cogs/Polls/functions/converters.py @@ -6,7 +6,8 @@ from tuxbot.cogs.Polls.functions.exceptions import ( ) from tuxbot.cogs.Polls.models import Poll -_ = lambda x: x + +def _(x): return x class PollConverter(commands.Converter): @@ -50,7 +51,7 @@ class PollConverter(commands.Converter): class NewPropositionConvertor(commands.Converter): - async def convert(self, ctx, argument): + async def convert(self, ctx, argument): # skipcq: PYL-W0613 if len(argument) > 30: raise TooLongProposition( _("Your proposal must be smaller than 30") diff --git a/tuxbot/cogs/Polls/polls.py b/tuxbot/cogs/Polls/polls.py index b34e2fd..1d7986f 100644 --- a/tuxbot/cogs/Polls/polls.py +++ b/tuxbot/cogs/Polls/polls.py @@ -166,11 +166,11 @@ class Polls(commands.Cog, name="Polls"): for i, field in enumerate(content.get("fields")): responders = responses.get(i, 0) - chart_options.get("data").get("labels").append( - field.get("name")[6:].replace("__", "") + chart_options["data"]["labels"].append( + field["name"][6:].replace("__", "") ) - chart_options.get("data").get("datasets")[0].get("data").append( + chart_options["data"]["datasets"][0].get("data").append( responders ) diff --git a/tuxbot/setup.py b/tuxbot/setup.py index 46bafbe..b83a747 100644 --- a/tuxbot/setup.py +++ b/tuxbot/setup.py @@ -8,7 +8,7 @@ import sys from argparse import Namespace from pathlib import Path from typing import Union, List -from urllib.request import urlopen +import requests from rich.prompt import Prompt, IntPrompt from rich.console import Console @@ -402,22 +402,18 @@ def basic_setup() -> None: def update() -> None: response = ( - urlopen( + requests.get( "https://api.github.com/repos/Rom1-J/tuxbot-bot/commits/master" - ) - .read() - .decode("utf-8") + ).json() ) - json_response = json.loads(response) - - if json_response.get("sha")[:6] == version_info.build: + if response.get("sha")[:6] == version_info.build: print( "Nothing to update, you can run `tuxbot [instance_name]` " "to start the bot" ) else: - print(f"Updating to {json_response.get('sha')[:6]}...") + print(f"Updating to {response.get('sha')[:6]}...") os.popen("/usr/bin/git pull")