initial commit
This commit is contained in:
commit
d9263b447e
1
README.txt
Normal file
1
README.txt
Normal file
@ -0,0 +1 @@
|
||||
Some additional modules for drastikbot https://github.com/olagood/drastikbot_modules
|
44
art.py
Normal file
44
art.py
Normal file
@ -0,0 +1,44 @@
|
||||
import requests
|
||||
import random
|
||||
import re
|
||||
|
||||
host = "https://collectionapi.metmuseum.org/public/collection/v1/"
|
||||
|
||||
# get the list of artwork
|
||||
r = requests.get(host + 'objects')
|
||||
objects = r.json()['objectIDs']
|
||||
|
||||
def getArt(term):
|
||||
searchObjects = objects
|
||||
if term:
|
||||
query = {'q': term, 'hasImages': 'true'}
|
||||
r = requests.get(host + 'search', params=query)
|
||||
searchObjects = r.json()['objectIDs']
|
||||
|
||||
if not searchObjects or len(searchObjects) == 0:
|
||||
return None
|
||||
|
||||
tries = 10
|
||||
while tries > 0:
|
||||
r = requests.get(host + 'objects/' + str(random.choice(searchObjects)))
|
||||
j = r.json()
|
||||
if j['primaryImage']:
|
||||
return j
|
||||
tries -= 1
|
||||
return None
|
||||
|
||||
class Module:
|
||||
def __init__(self):
|
||||
self.commands = ['art']
|
||||
self.manual = {
|
||||
"desc": ("Post random art from metmuseum's api"),
|
||||
"bot_commands": {"art": {"usage": lambda x: f"{x}art"}}
|
||||
}
|
||||
|
||||
def main(i, irc):
|
||||
msg = getArt("")
|
||||
if msg is None:
|
||||
msg = "No result"
|
||||
else
|
||||
msg = '"' + msg['title'] + '" ' + msg['objectDate'] + ' ' + msg['primaryImage']
|
||||
irc.privmsg(i.channel, msg)
|
68
radio.py
Normal file
68
radio.py
Normal file
@ -0,0 +1,68 @@
|
||||
host = "http://localhost:5000/"
|
||||
radioUrl = "https://radio.neet.space/stream.mp3"
|
||||
|
||||
class Module:
|
||||
def __init__(self):
|
||||
self.commands = ["dailyradio",
|
||||
"play",
|
||||
"current",
|
||||
"skip",
|
||||
"queue",
|
||||
"listeners"]
|
||||
self.manual = {
|
||||
"desc": "Stream and radio information for dailyradio",
|
||||
"bot_commands": {
|
||||
"dailyradio": {"usage": lambda x: f"{x}dailyradio",
|
||||
"info": "Display the dailyradio stream url."},
|
||||
"play": {"usage": lambda x: f"{x}play URL",
|
||||
"info": "plays the url on the radio."},
|
||||
"current": {"usage": lambda x: f"{x}current",
|
||||
"info": "Gets what's currently playing on the radio."},
|
||||
"skip": {"usage": lambda x: f"{x}skip",
|
||||
"info": "Skips what's currently playing on the radio."},
|
||||
"queue": {"usage": lambda x: f"{x}queue",
|
||||
"info": "Gets the radio's play queue"},
|
||||
"listeners": {"usage": lambda x: f"{x}listeners",
|
||||
"info": "Returns the number of clients listening to the radio"}
|
||||
}
|
||||
}
|
||||
|
||||
def dailyradio(i, irc):
|
||||
irc.privmsg(i.channel, radioUrl)
|
||||
|
||||
def play(i, irc):
|
||||
if not i.msg_nocmd:
|
||||
m = f"Usage: {i.cmd_prefix}{i.cmd} URL"
|
||||
irc.privmsg(i.channel, m)
|
||||
return
|
||||
pload = {'url': message[len(".play "):]}
|
||||
r = requests.post(host+"play", data = pload)
|
||||
irc.privmsg(i.channel, r.text)
|
||||
|
||||
def current(i, irc):
|
||||
r = requests.get(host+"current")
|
||||
irc.privmsg(i.channel, r.text)
|
||||
|
||||
def skip(i, irc):
|
||||
r = requests.get(host+"skip")
|
||||
irc.privmsg(i.channel, r.text)
|
||||
|
||||
def queue(i, irc):
|
||||
r = requests.get(host+"queue")
|
||||
irc.privmsg(i.channel, r.text)
|
||||
|
||||
def listeners(i, irc):
|
||||
r = requests.get(host+"listeners")
|
||||
irc.privmsg(i.channel, r.text)
|
||||
|
||||
callbacks = {
|
||||
"dailyradio": dailyradio,
|
||||
"play": play,
|
||||
"current": current,
|
||||
"skip": skip,
|
||||
"queue": queue,
|
||||
"listeners": listeners
|
||||
}
|
||||
|
||||
def main(i, irc):
|
||||
callbacks[i.cmd](i, irc)
|
Loading…
x
Reference in New Issue
Block a user