2020-08-31 20:30:07 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import time
|
|
|
|
|
|
|
|
import requests
|
|
|
|
from signald import Signal
|
|
|
|
|
|
|
|
s = Signal(os.environ["SIGNAL_NUMBER"])
|
|
|
|
|
2020-08-31 20:57:17 -04:00
|
|
|
@s.chat_handler(re.compile("^[\.\/]wuvt.*", re.IGNORECASE))
|
2020-08-31 20:30:07 -04:00
|
|
|
def wuvt(message, match):
|
|
|
|
r = requests.get('https://www.wuvt.vt.edu/playlists/latest_track', headers={'Accept': "application/json"})
|
|
|
|
trackinfo = r.json()
|
|
|
|
|
|
|
|
if 'listeners' in trackinfo and trackinfo['listeners'] is not None:
|
|
|
|
return str(
|
|
|
|
"{dj} is currently playing \"{title}\" by {artist} with "
|
|
|
|
"{listeners:d} online listeners".format(
|
|
|
|
dj=trackinfo['dj'],
|
|
|
|
title=trackinfo['title'],
|
|
|
|
artist=trackinfo['artist'],
|
|
|
|
listeners=trackinfo['listeners']))
|
|
|
|
else:
|
|
|
|
return str("{dj} is currently playing \"{title}\" by {artist}".format(
|
|
|
|
dj=trackinfo['dj'],
|
|
|
|
title=trackinfo['title'],
|
|
|
|
artist=trackinfo['artist']))
|
|
|
|
|
|
|
|
def divide(input, by):
|
|
|
|
return (input // by), (input % by)
|
|
|
|
|
2020-08-31 20:57:17 -04:00
|
|
|
@s.chat_handler(re.compile("^[\.\/]yi.*", re.IGNORECASE))
|
2020-08-31 20:30:07 -04:00
|
|
|
def yi(message, match):
|
|
|
|
quadraels, remainder = divide(int(time.time()), 1753200)
|
|
|
|
raels = quadraels * 4
|
|
|
|
extraraels, remainder = divide(remainder, 432000)
|
|
|
|
if extraraels == 4:
|
|
|
|
return('Yes! PARTAI!')
|
|
|
|
elif extraraels == 3:
|
|
|
|
return('Soon...')
|
|
|
|
else:
|
|
|
|
return('Not yet...')
|
|
|
|
|
|
|
|
s.run_chat()
|