From 11de44cc7de3271fbb29a03addfde0c1529b5edb Mon Sep 17 00:00:00 2001 From: Kamal Curi Date: Sat, 20 Aug 2022 18:53:15 -0300 Subject: [PATCH] CHANGE: Using pyre was stupid. I am stupid --- requirements/common.txt | 4 +--- utils/commands.py | 6 +++--- utils/weather.py | 15 +++++++-------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/requirements/common.txt b/requirements/common.txt index 35d922c..2cf0f62 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -1,5 +1,3 @@ -Cython discord.py mysqlclient -SQLAlchemy -pyre2 \ No newline at end of file +SQLAlchemy \ No newline at end of file diff --git a/utils/commands.py b/utils/commands.py index 46a1513..969cf05 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -3,9 +3,9 @@ Bot commands. """ import logging from random import choice -import re2 from discord.ext import commands +from discord import Intents from settings.config import IMAGE_TYPES, PERMISSIONS from utils.database import get_by_id, get_quotes, remove_quote, set_quote, count_quotes @@ -15,7 +15,7 @@ from settings.config import PERMISSIONS, OW_API_CONFIG from utils.database import (count_quotes, get_by_id, get_quote_contains, get_quotes, remove_quote, set_quote) -client = commands.Bot(command_prefix='--') +client = commands.Bot(command_prefix='--', intents=Intents.all()) logger = logging.getLogger(__name__) quote_id_stack = [] @@ -196,7 +196,7 @@ async def weather(bot: object, *location: str) -> str: (The weather command hansn't been set up properly, make sure you have `OPENWEATHER_API_TOKEN` set up") if location: location = str(location) - stripped = re2.sub(" ", "", location) # Strips all whitespace + stripped = location.replace(" ", "") # Strips all whitespace separated = stripped.split(',') # Splits between commas separated.pop(-1) separated[0] = separated[0][1:len(separated[0])] # These two commands clean up input for the parser diff --git a/utils/weather.py b/utils/weather.py index b672cb7..b3a3624 100644 --- a/utils/weather.py +++ b/utils/weather.py @@ -4,7 +4,6 @@ from settings.config import OW_API_CONFIG import urllib.request import json -import re2 def geocode(city = 'curitiba', state = 'parana', country = 'BR') -> str: """ @@ -15,10 +14,10 @@ def geocode(city = 'curitiba', state = 'parana', country = 'BR') -> str: state = 'parana' country = 'BR' ow_gc_url = OW_API_CONFIG['gc_url'] - ow_gc_url = re2.sub('', city, ow_gc_url) - ow_gc_url = re2.sub('', state, ow_gc_url) - ow_gc_url = re2.sub('', OW_API_CONFIG['api_id'], ow_gc_url) + ow_gc_url = ow_gc_url.replace('', city) + ow_gc_url = ow_gc_url.replace('', state) + ow_gc_url = ow_gc_url.replace('', OW_API_CONFIG['api_id']) placedata = urllib.request.urlopen(ow_gc_url) placedata = placedata.read().decode() @@ -31,9 +30,9 @@ def getweatherdata(lat, lon): Gets weather data based on coordinates """ ow_wh_url = OW_API_CONFIG['wh_url'] - ow_wh_url = re2.sub('', lat, ow_wh_url) - ow_wh_url = re2.sub('', lon, ow_wh_url) - ow_wh_url = re2.sub('', OW_API_CONFIG['api_id'], ow_wh_url) + ow_wh_url = ow_wh_url.replace('', lat) + ow_wh_url = ow_wh_url.replace('', lon) + ow_wh_url = ow_wh_url.replace('', OW_API_CONFIG['api_id']) weatherdata = urllib.request.urlopen(ow_wh_url) weatherdata = weatherdata.read().decode()