-
-
Save v2px/5049894 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mechanize' | |
require 'xmlsimple' | |
plugin = Plugin.new "icecast" | |
plugin.handle(/^stream$/i) do |data| | |
next data[:room].say "Punkrockers Stream: http://stream.punkrockers-radio.de:8000/prr" | |
end | |
plugin.handle(/^np$/i) do |data| | |
# icecast server details | |
server = 'example.net' | |
port = 8000 | |
user = 'gist' | |
password = 'hackme' | |
mount = '/listen' | |
# connect and get status xml | |
agent = Mechanize.new | |
agent.user_agent_alias = 'Linux Firefox' | |
agent.add_auth("http://#{server}:#{port}/admin/status.xml", user, password) | |
agent.get("http://#{server}:#{port}/admin/status.xml") | |
page = agent.current_page.content.to_s | |
xml = XmlSimple.xml_in(page) | |
# check status of mount point | |
xml['source'].each do |source| | |
# if correct mount point, get status info | |
if source['mount'].eql? mount | |
status = "Jetzt im Radio: " + source['title'].join + " (" + source['server_name'].join + ": " + source['listeners'].join + " H\u{F6}rer)" | |
end | |
end | |
next data[:room].say status | |
end | |
$bot.plugins.add(plugin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment