Skip to content

Instantly share code, notes, and snippets.

@karlsander
Created June 26, 2013 18:06
Show Gist options
  • Save karlsander/5869809 to your computer and use it in GitHub Desktop.
Save karlsander/5869809 to your computer and use it in GitHub Desktop.
jenni user timezone module
import times
import json
filename = 'timezones.json'
timezones = {}
try:
timezones = json.load(open(filename))
except:
pass
def user_time(phenny, input):
now = times.now()
input_list = input.group().split()
if(input_list[1] in timezones):
output = times.format(now, timezones[input_list[1]], '%X')
else:
output = "Sorry, I don't know that user. You should add her"
phenny.say(output)
def add_user(phenny, input):
input_list = input.group().split()
timezones[input.nick] = input_list[1]
json.dump(timezones, open(filename, 'wb'))
output = "Timezone " + input_list[1] + " added for user " + input.nick
phenny.say(output)
user_time.commands = ['time']
user_time.priority = 'medium'
user_time.example = "You can add your timezone with the command .add_time followed by your timezone. Pick your timezone from this list https://en.wikipedia.org/wiki/List_of_tz_database_time_zones and use the format \"Europe/Berlin\""
add_user.commands = ['add_time']
add_user.priority = 'medium'
add_user.example = "You can add your timezone with the command .add_time followed by your timezone. Pick your timezone from this list https://en.wikipedia.org/wiki/List_of_tz_database_time_zones and use the format \"Europe/Berlin\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment