Skip to content

Instantly share code, notes, and snippets.

@mseymour
Created December 27, 2011 01:25
Show Gist options
  • Save mseymour/1522456 to your computer and use it in GitHub Desktop.
Save mseymour/1522456 to your computer and use it in GitHub Desktop.
DJ info from YAML (debugging version)
---
mli:
My site: http://insomniafanfics.weebly.com
Tumblr: http://mylittleinsomnia.tumblr.com
Facebook: http://www.facebook.com/profile.php?id=100001428581452
PonySquare: http://ponysquare.com/profile-2220/
Twitter: https://twitter.com/#!/DJINs0mnIAK
Skype: legit.sketchy
E-mail: insomnia@ponify.me
XboxLIVE Gamertag: ThatGuyEcho
Steam: http://steamcommunity.com/id/mylittleinsomnia
ponytoast:
Tumblr: ponytoast.tumblr.com
PonySquare: http://ponysquare.com/profile-2143/
Skype: PonyToast
BTR: http://blogtalkradio.com/djzan
Twitter: @TrueEquestria
E-mail: ponytoast@musician.org
# ...
c.plugins.options[Plugins::DJInfo] = { dj_info: File.dirname(__FILE__) + '/config/cr_dj_info.yaml' }
# ...
require 'yaml'
require 'ap'
module Plugins
class DJInfo
include Cinch::Plugin
set plugin_name: "DJ Info", help: "Spams the channel with DJ contact information.\nUsage: `!dj <dj_name>`", required_options: [:dj_info]
match /dj\s?(.+)?/
def execute (m, target)
@bot.loggers.debug "DJInfo: loading config from \"#{config[:dj_info]}\"..."
ap YAML::load_file(config[:dj_info])
@bot.loggers.debug "Trying to continue..."
info = YAML::load_file(config[:dj_info])
@bot.loggers.debug "DJInfo: loaded config:"
ap info
if !target.nil? && info.has_key?(target.downcase)
@bot.loggers.debug "DJInfo: info has key #{target.downcase} and target is not nil"
info[target.downcase].each {|key,item|
@bot.loggers.debug "#{key}: #{item}"
m.reply "#{key}: #{item}"
}
elsif target.nil?
@bot.loggers.debug "DJInfo: target is nil"
m.user.notice "DJInfo: No DJ name was supplied."
else
@bot.loggers.debug "DJInfo: target not found."
m.user.notice "\"#{target}\" is not a DJ, sorry."
end
end
end
end
[2011/12/26 20:19:37.609] >> :Azure!~azt@unaffiliated/azure PRIVMSG Aiko :!dj
[2011/12/26 20:19:37.612] !! [New thread] For #<Cinch::Handler @event=:message pattern=#<Cinch::Pattern:0x00000001e33f90 @prefix=/^!/, @pattern=/dj\s?(.+)?/, @suffix=nil>>: #<Thread:0x00000001ec93b0> -- 1 in total.
[2011/12/26 20:19:37.612] !! DJInfo: loading config from "./bots/config/cr_dj_info.yaml"...
[2011/12/26 20:19:37.612] !! [New thread] For #<Cinch::Handler @event=:private pattern=#<Cinch::Pattern:0x00000001e6cf20 @prefix=nil, @pattern=//, @suffix=nil>>: #<Thread:0x00000001eb6cd8> -- 1 in total.
[2011/12/26 20:19:37.613] !! [New thread] For #<Cinch::Handler @event=:message pattern=#<Cinch::Pattern:0x00000001e22010 @prefix=/^!/, @pattern=/(.+)$/i, @suffix=nil>>: #<Thread:0x00000001ec9658> -- 1 in total.
[2011/12/26 20:19:37.613] !! [Thread done] For #<Cinch::Handler @event=:private pattern=#<Cinch::Pattern:0x00000001e6cf20 @prefix=nil, @pattern=//, @suffix=nil>>: #<Thread:0x00000001eb6cd8> -- 0 remaining.
[2011/12/26 20:19:37.613] !! [Thread done] For #<Cinch::Handler @event=:message pattern=#<Cinch::Pattern:0x00000001e33f90 @prefix=/^!/, @pattern=/dj\s?(.+)?/, @suffix=nil>>: #<Thread:0x00000001ec93b0> -- 0 remaining.
[2011/12/26 20:19:37.613] !! [Thread done] For #<Cinch::Handler @event=:message pattern=#<Cinch::Pattern:0x00000001e22010 @prefix=/^!/, @pattern=/(.+)$/i, @suffix=nil>>: #<Thread:0x00000001ec9658> -- 0 remaining.
[2011/12/26 20:21:29.253] << PING 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment