Added now playing command for ToukuFM
parent
56fc002d07
commit
67a1b2cc0f
|
@ -15,4 +15,8 @@ owner_id:
|
||||||
|
|
||||||
#Reddit Stuff
|
#Reddit Stuff
|
||||||
reddit_client_id:
|
reddit_client_id:
|
||||||
reddit_client_secret:
|
reddit_client_secret:
|
||||||
|
|
||||||
|
#Icecast Stuff
|
||||||
|
metadataurl:
|
||||||
|
iceurl:
|
|
@ -18,4 +18,5 @@
|
||||||
**!joke**: Posts a random joke from /r/Jokes
|
**!joke**: Posts a random joke from /r/Jokes
|
||||||
**!8ball**: You ask a question, it answeres. Simple!
|
**!8ball**: You ask a question, it answeres. Simple!
|
||||||
**!conch** or **!magicconch**: Same as the 8ball command but waaaaay cooler
|
**!conch** or **!magicconch**: Same as the 8ball command but waaaaay cooler
|
||||||
**!giveaway prize**: Do a giveaway based on users reacting with the emoji you react with secretly. Use in private and replace prize with an actual prize!
|
**!giveaway prize**: Do a giveaway based on users reacting with the emoji you react with secretly. Use in private and replace prize with an actual prize!
|
||||||
|
**!np**: Posts currently playing info for ToukuFM
|
38
pocketbot.py
38
pocketbot.py
|
@ -7,6 +7,8 @@ import random
|
||||||
import xkcd
|
import xkcd
|
||||||
import praw
|
import praw
|
||||||
import os
|
import os
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
#Get script location
|
#Get script location
|
||||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
@ -26,6 +28,10 @@ reddit_client_secret = config.get("configuration", "reddit_client_secret")
|
||||||
reddit_user_agent = 'linux:com.pocketjawa.discord-pocketbot:v0.1 (by /u/pocketjava)'
|
reddit_user_agent = 'linux:com.pocketjawa.discord-pocketbot:v0.1 (by /u/pocketjava)'
|
||||||
reddit = praw.Reddit(client_id=reddit_client_id,client_secret=reddit_client_secret,user_agent=reddit_user_agent)
|
reddit = praw.Reddit(client_id=reddit_client_id,client_secret=reddit_client_secret,user_agent=reddit_user_agent)
|
||||||
|
|
||||||
|
#Icecast stream info setup
|
||||||
|
metadataurl = config.get("configuration", "metadataurl")
|
||||||
|
iceurl = config.get("configuration", "iceurl")
|
||||||
|
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
|
|
||||||
#Subroutine to get UPS Status
|
#Subroutine to get UPS Status
|
||||||
|
@ -207,6 +213,38 @@ def on_message(message):
|
||||||
#Congratulate and ,essage the winner
|
#Congratulate and ,essage the winner
|
||||||
yield from client.send_message(public_channel_id, 'Congrats to {0.user}!'.format(res))
|
yield from client.send_message(public_channel_id, 'Congrats to {0.user}!'.format(res))
|
||||||
yield from client.send_message(res.user, args)
|
yield from client.send_message(res.user, args)
|
||||||
|
#Get currently playing stats from toukufm.com
|
||||||
|
elif message.content.lower().startswith('!np'):
|
||||||
|
|
||||||
|
#Load JSON from stream APIs
|
||||||
|
nprequest = requests.get(metadataurl)
|
||||||
|
npobject = json.loads(nprequest.text)
|
||||||
|
icerequest = requests.get(iceurl)
|
||||||
|
iceobject = json.loads(icerequest.text)
|
||||||
|
|
||||||
|
#Add up listeners
|
||||||
|
listenersum = int(0)
|
||||||
|
for stream in iceobject['icestats']['source']:
|
||||||
|
listenersum += stream["listeners"]
|
||||||
|
|
||||||
|
#Put together the message
|
||||||
|
output = ""
|
||||||
|
if 'comment' in npobject:
|
||||||
|
output += "[{}]".format(npobject['comment'])
|
||||||
|
if 'artist' in npobject:
|
||||||
|
output += "\n{} - ".format(npobject['artist'])
|
||||||
|
if 'title' in npobject:
|
||||||
|
if 'artist' in npobject:
|
||||||
|
output += "{} ".format(npobject['title'])
|
||||||
|
else:
|
||||||
|
output += "\n{} ".format(npobject['title'])
|
||||||
|
if 'WOAR' in npobject:
|
||||||
|
output += "\nDownload/Buy: {}".format(npobject['WOAR'])
|
||||||
|
output += "\nListeners: {} ".format(listenersum)
|
||||||
|
|
||||||
|
#Set embed and send the message
|
||||||
|
npem = discord.Embed(title="Now Playing on ToukuFM", description=output, url="https://toukufm.com/")
|
||||||
|
yield from client.send_message(message.channel, embed=npem)
|
||||||
|
|
||||||
|
|
||||||
client.loop.create_task(ups_check())
|
client.loop.create_task(ups_check())
|
||||||
|
|
Loading…
Reference in New Issue