Adjust gti
This commit is contained in:
parent
70535d0399
commit
cc9a934fe6
@ -4,6 +4,7 @@ import asyncio
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext.commands.formatter import Paginator
|
from discord.ext.commands.formatter import Paginator
|
||||||
from . import checks
|
from . import checks
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class Capturing(list):
|
class Capturing(list):
|
||||||
@ -64,6 +65,11 @@ def to_list_of_str(items, out: list=list(), level=1, recurse=0):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def replace_text_ignorecase(in_str: str, old: str, new: str='') -> str:
|
||||||
|
re_replace = re.compile(re.escape(old), re.IGNORECASE)
|
||||||
|
return re_replace.sub(f'{new}', in_str)
|
||||||
|
|
||||||
|
|
||||||
def paginate(text, maxlen=1990):
|
def paginate(text, maxlen=1990):
|
||||||
paginator = Paginator(prefix='```py', max_size=maxlen+10)
|
paginator = Paginator(prefix='```py', max_size=maxlen+10)
|
||||||
if type(text) == list:
|
if type(text) == list:
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import psutil
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import asyncio
|
import asyncio
|
||||||
import async_timeout
|
import async_timeout
|
||||||
from .imports import checks
|
from .imports import checks, utils
|
||||||
import pytz
|
import pytz
|
||||||
import gspread
|
import gspread
|
||||||
from oauth2client.service_account import ServiceAccountCredentials
|
from oauth2client.service_account import ServiceAccountCredentials
|
||||||
@ -31,6 +31,7 @@ invite_match = '(https?://)?(www.)?discord(app.com/(invite|oauth2)|.gg|.io)/[\w\
|
|||||||
|
|
||||||
utils_log = logging.getLogger('utils')
|
utils_log = logging.getLogger('utils')
|
||||||
clock_emojis = ['🕛', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚']
|
clock_emojis = ['🕛', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚']
|
||||||
|
replace_tzs = {'MST': 'US/Mountain', 'HST': 'US/Hawaii', 'EST': 'US/Eastern'}
|
||||||
|
|
||||||
|
|
||||||
class Utils:
|
class Utils:
|
||||||
@ -471,8 +472,12 @@ class Utils:
|
|||||||
try:
|
try:
|
||||||
orig_time = copy(time)
|
orig_time = copy(time)
|
||||||
for tz in pytz.all_timezones:
|
for tz in pytz.all_timezones:
|
||||||
if tz.lower() in time.lower():
|
if any([t.replace(' ', '_') in tz.lower()
|
||||||
time = time.replace(tz, '')
|
or t.replace(' ', '-') in tz.lower()
|
||||||
|
for t in time.lower().split()]):
|
||||||
|
time = utils.replace_text_ignorecase(time, old=tz, new='')
|
||||||
|
if tz in replace_tzs:
|
||||||
|
tz = replace_tzs['tz']
|
||||||
parsed_tz = pytz.timezone(tz)
|
parsed_tz = pytz.timezone(tz)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@ -487,7 +492,6 @@ class Utils:
|
|||||||
f'Examples of valid time strings are in my help documentation.\n' \
|
f'Examples of valid time strings are in my help documentation.\n' \
|
||||||
f'Please try again.'
|
f'Please try again.'
|
||||||
em.colour = discord.Colour.red()
|
em.colour = discord.Colour.red()
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
out_tz = pytz.timezone(timezone)
|
out_tz = pytz.timezone(timezone)
|
||||||
except pytz.exceptions.UnknownTimeZoneError:
|
except pytz.exceptions.UnknownTimeZoneError:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user