Class: BPCI::IRCBot
- Inherits:
-
Object
- Object
- BPCI::IRCBot
- Defined in:
- lib/bpci/irc.rb
Instance Attribute Summary collapse
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
Instance Method Summary collapse
- #broadcast(text) ⇒ Object
-
#initialize(project_path) ⇒ IRCBot
constructor
A new instance of IRCBot.
Constructor Details
#initialize(project_path) ⇒ IRCBot
Returns a new instance of IRCBot.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bpci/irc.rb', line 10 def initialize(project_path) irc_nick = Config.bpci(project_path).ircnick.to_s irc_channels = Config.bpci(project_path).ircchannels.to_s @channels = "#{irc_channels}".split(',') irc_network = Config.bpci(project_path).ircnetwork.to_s irc_port = Config.bpci(project_path).ircport @bot = IRC.new do nick irc_nick ident 'bpci' realname 'Breakpoint CI Bot' server :bpci do address irc_network port "#{irc_port}".to_i end end @bot.on '001' do join irc_channels end @bot.on :privmsg do case params[1] when '!ping' irc_channels.split(',').each do |channel| @bot[:bpci].msg channel, 'hi' end when /^#{irc_nick}[:,] build$/ Thread.new do Net::HTTP.post_form(URI.parse("http://localhost:#{$port}/"), {'rebuild' => 'true'}) end end end @bot.on :ping do pong params[0] end @bot.connect end |
Instance Attribute Details
#bot ⇒ Object (readonly)
Returns the value of attribute bot.
8 9 10 |
# File 'lib/bpci/irc.rb', line 8 def bot @bot end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
8 9 10 |
# File 'lib/bpci/irc.rb', line 8 def channels @channels end |
Instance Method Details
#broadcast(text) ⇒ Object
51 52 53 54 55 |
# File 'lib/bpci/irc.rb', line 51 def broadcast(text) @channels.each do |channel| @bot[:bpci].msg channel, text end end |