Automatically rename 'Calcutta' to 'Kolkata'

This commit is contained in:
Noi 2021-10-06 20:17:20 -07:00
parent 660260b50f
commit 32804aa9b2
2 changed files with 9 additions and 5 deletions

View file

@ -125,12 +125,14 @@ class WtCommands:
await channel.send(':x: Zone parameter is required.') await channel.send(':x: Zone parameter is required.')
return return
try: try:
zoneinput = tzlcmap[wspl[1].lower()] userinput = wspl[1].lower()
if userinput == "asia/calcutta": userinput = "asia/kolkata"
zoneinput = tzlcmap[userinput]
except KeyError: except KeyError:
await channel.send(self.errStrInvalidZone) await channel.send(self.errStrInvalidZone)
return return
self.userdb.update_user(guild.id, author.id, zoneinput) self.userdb.update_user(guild.id, author.id, zoneinput)
await channel.send(':white_check_mark: Your zone has been set.') await channel.send(f':white_check_mark: Your time zone has been set to **{zoneinput}**.')
async def cmd_setFor(self, guild: discord.Guild, channel: discord.TextChannel, author: discord.User, msgcontent: str): async def cmd_setFor(self, guild: discord.Guild, channel: discord.TextChannel, author: discord.User, msgcontent: str):
if not self._isUserAdmin(author): if not self._isUserAdmin(author):
@ -155,14 +157,16 @@ class WtCommands:
# Check the third parameter # Check the third parameter
try: try:
zoneinput = tzlcmap[wspl[2].lower()] userinput = wspl[2].lower()
if userinput == "asia/calcutta": userinput = "asia/kolkata"
zoneinput = tzlcmap[userinput]
except KeyError: except KeyError:
await channel.send(self.errStrInvalidZone) await channel.send(self.errStrInvalidZone)
return return
# Do the thing # Do the thing
self.userdb.update_user(guild.id, targetuser.id, zoneinput) self.userdb.update_user(guild.id, targetuser.id, zoneinput)
await channel.send(':white_check_mark: Set zone for **' + targetuser.name + '#' + targetuser.discriminator + '**.') await channel.send(f':white_check_mark: Time zone for **{targetuser.name}#{targetuser.discriminator}** set to **{zoneinput}**.')
async def cmd_list(self, guild: discord.Guild, channel: discord.TextChannel, author: discord.User, msgcontent: str): async def cmd_list(self, guild: discord.Guild, channel: discord.TextChannel, author: discord.User, msgcontent: str):
wspl = msgcontent.split(' ', 1) wspl = msgcontent.split(' ', 1)

View file

@ -4,7 +4,7 @@ import pytz
from datetime import datetime from datetime import datetime
# Bot's current version (as a string), for use in the help command # Bot's current version (as a string), for use in the help command
BotVersion = "1.3.3" BotVersion = "1.3.4"
# For case-insensitive time zone lookup, map lowercase tzdata entries with # For case-insensitive time zone lookup, map lowercase tzdata entries with
# entires with proper case. pytz is case sensitive. # entires with proper case. pytz is case sensitive.