forked from Thema89/discord-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highnoon.py
42 lines (36 loc) · 1.36 KB
/
highnoon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from datetime import datetime
import pytz
from pytz import timezone as timezone
import discord
import asyncio
import random
tzs = []
banned_tzs = ['CET','CST6DT','EET','EST','EST5EDT','GMT','Greenwhich','UTC','Zulu','Universal','GB','HST','MET','MST','MST7MDT','NZ','PRC','PST8PDT','ROC','ROK','UCT','WET','W-SU']
async def where(message, client):
while True:
await client.send_typing(message.channel)
for tz in pytz.all_timezones:
h_tz = datetime.now(timezone(tz)).hour
if h_tz == 12:
tzs.append(tz)
if not tzs:
await client.send_message(message.channel, "It isn't Hign Noon anywhere somehow?!")
break
else:
for tmzn in tzs:
if any(tmz in tmzn for tmz in banned_tzs):
tzs.remove(tmzn)
if not tzs:
await client.send_message(message.channel, "It's High Noon somewhere... we just can't really describe where...")
break
tmp1 = random.choice(tzs)
loc = 0
if '/' in tmp1:
tmp1 = tmp1.split("/")
tmp2 = tmp1[1].split("_")
loc = " ".join(tmp2)
else:
loc = tmp1
msg = "It's High Noon in %s" % loc
await client.send_message(message.channel, msg)
break