slashhardcore.rb is a station tuner for Digitally Imported radio

29 Aug 2007

I updated this script! Forgot to bind the /hardcore command before. Grab it now!

I was surprised how easy it is to write an XChat plugin in Ruby, even though it would be cooler to see a the xchat-ruby bindings pimped out DSL style…oh well.

Download slashhardcore.rb

Windows users must modify @launcher to the path to their Winamp, Firefox, IE, or other shoutcast-compatible player.

# slashhardcore.rb - A faster way to tune in than the playlist bot.
# Should work on Windows if you set a valid browser/winamp location.
# Usage: Put in your $HOME/.xchat2 directory to autoload, and restart xchat,
# or type "/load /path/to/slashhardcore.rb"
# Commands: /pls <station, /stations (list stations), /hardcore
# Author: Logan Koester <>

include XChatRuby

class SlashHardcore < XChatRubyPlugin

	attr_accessor :launcher

	def initialize( plugin )
		@launcher = "/usr/bin/firefox"
		hook_command( "pls", XCHAT_PRI_NORM,
			method ( :pls ),
			"Use /pls <station> to tune in. Use /stations to check list
			of stations at"
		hook_command( "stations", XCHAT_PRI_NORM,
			method ( :stations_list ),
			"Fetches an updated list of stations"
		hook_command( "hardcore", XCHAT_PRI_NORM,
			method ( :hardcore ),
			"Tunes into the radio stream"
		puts_fmt "Digitally Imported!"

	# Alias for /pls hardcore
	def hardcore (words, words_eol, data)
		puts_fmt "Hardcore is good for you!"
		play "hardcore"
		return XCHAT_EAT_ALL

	# Tunes you in using your browses's default application
	# for *.pls files
	def pls (words, words_eol, data)
		station = words[1]
		puts_fmt "Tuning into #{station} (using #{@launcher})"
		@plugin.command( "/msg #candyball test" )
		play station
		return XCHAT_EAT_ALL

	def play (station)
		exec "#{@launcher}{station}.pls" if fork == nil

	# Returns the playlist filenames of playlists at
	def stations_list (words, words_eol, data)
		require 'open-uri'
		uri = ""
		index = URI.parse uri
		list ="\/mp3\/(.*)\.pls/).flatten
		puts_fmt list.join ", " # CSV string
		return XCHAT_EAT_ALL
blog comments powered by Disqus