Module: IRC::Motor
- Defined in:
- lib/irc-qik-bot/irc-motor.rb
Class Method Summary collapse
- .admin_input ⇒ Object
- .channel(channel = nil) ⇒ Object
- .channel_input ⇒ Object
- .connect(server, port = "6667") ⇒ Object
- .err(msg) ⇒ Object
- .in_channel ⇒ Object
- .ircsend(msg) ⇒ Object
- .join_channel(irc_chanl, irc_nick = "qbot") ⇒ Object
- .nick(nick = nil) ⇒ Object
- .ymlconf ⇒ Object
Class Method Details
.admin_input ⇒ Object
53 54 55 56 57 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 53 def self.admin_input return if $stdin.eof irc_command = $stdin.gets ircsend irc_command end |
.channel(channel = nil) ⇒ Object
17 18 19 20 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 17 def self.channel(channel=nil) @channel = channel unless channel.nil? @channel end |
.channel_input ⇒ Object
59 60 61 62 63 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 59 def self.channel_input return if @irc.eof irc_stream = @irc.gets IRC::Handlers.channel self, irc_stream end |
.connect(server, port = "6667") ⇒ Object
22 23 24 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 22 def self.connect(server, port="6667") @irc = IRC::Handlers.socket server, port end |
.err(msg) ⇒ Object
73 74 75 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 73 def self.err(msg) STDERR.puts "ERROR: #{msg}" end |
.in_channel ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 39 def self.in_channel while true ready = select([@irc, $stdin], nil) next if !ready for status in ready[0] if status == $stdin then admin_input elsif status == @irc then channel_input end end end end |
.ircsend(msg) ⇒ Object
26 27 28 29 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 26 def self.ircsend(msg) return err("No IRC Connection Found") unless @irc @irc.send "#{msg}\n", 0 end |
.join_channel(irc_chanl, irc_nick = "qbot") ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 31 def self.join_channel(irc_chanl, irc_nick="qbot") channel irc_chanl nick irc_nick ircsend "USER irc qik bot :#{ENV['USERNAME']} qbot" ircsend "NICK #{nick}" ircsend "JOIN #{channel}" end |
.nick(nick = nil) ⇒ Object
12 13 14 15 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 12 def self.nick(nick=nil) @nick = nick unless nick.nil? @nick end |
.ymlconf ⇒ Object
65 66 67 68 69 70 |
# File 'lib/irc-qik-bot/irc-motor.rb', line 65 def self.ymlconf require 'yaml' resource_dir = File. File.join(File.dirname(__FILE__), '..', '..', 'resource') irc_yaml = File.join resource_dir, 'irc.yaml' YAML.load_file irc_yaml end |