Class: ModSpox::Bot
- Inherits:
-
Object
- Object
- ModSpox::Bot
- Defined in:
- lib/mod_spox/Bot.rb
Instance Attribute Summary collapse
-
#dcc_sockets ⇒ Object
readonly
DCC sockets.
-
#factory ⇒ Object
readonly
message factory.
-
#pipeline ⇒ Object
readonly
message pipeline.
-
#plugin_manager ⇒ Object
readonly
plugin manager.
-
#pool ⇒ Object
readonly
thread pool.
-
#timer ⇒ Object
readonly
bot timer.
Instance Method Summary collapse
-
#admin(message) ⇒ Object
- message
-
Messages::Outgoing::Admin message Sends ADMIN message to server.
-
#away(message) ⇒ Object
- message
-
Messages::Outgoing::Away message Sends AWAY message to server.
-
#bot_connect(message) ⇒ Object
- message
-
Messages::Internal::EstablishConnection message Initialize connection to IRC server.
-
#bot_stats ⇒ Object
Returns status of the bot in a formatted string.
-
#channel_mode(message) ⇒ Object
- message
-
Messages::Outgoing::ChannelMode message Sends MODE message to server.
- #check_join(m) ⇒ Object
- #check_part(m) ⇒ Object
-
#clear_timer(message) ⇒ Object
- message
-
Messages::Internal::TimerClear Clear all actions from timer.
-
#connect(message) ⇒ Object
- message
-
Messages::Outgoing::Connect message Sends CONNECT message to server.
-
#die(message) ⇒ Object
- message
-
Messages::Outgoing::Die message Sends DIE message to server.
-
#disconnected(message) ⇒ Object
- message
-
Messages::Internal::Disconnected Disconnect the bot from the IRC server.
-
#get_nick(message) ⇒ Object
- message
-
Messages::Internal::NickRequest Sends the bot’s nick to plugins.
-
#halt(message = nil) ⇒ Object
Stop the bot.
-
#hook_pipeline ⇒ Object
Adds hooks to pipeline for processing messages.
-
#info(message) ⇒ Object
- message
-
Messages::Outgoing::Info message Sends INFO message to server.
-
#initialize ⇒ Bot
constructor
Create a Bot.
-
#invite(message) ⇒ Object
- message
-
Messages::Outgoing::Invite message Sends INVITE message to server.
-
#ison(message) ⇒ Object
- message
-
Messages::Outgoing::Ison message Sends ISON message to server.
-
#join(message) ⇒ Object
- message
-
Messages::Outgoing::Join message Sends JOIN message to server.
-
#kick(message) ⇒ Object
- message
-
Messages::Outgoing::Kick message Sends KICK message to server.
-
#kill(message) ⇒ Object
- message
-
Messages::Outgoing::Kill message Sends KILL message to server.
-
#links(message) ⇒ Object
- message
-
Messages::Outgoing::Links message Sends LINKS message to server.
-
#list(message) ⇒ Object
- message
-
Messages::Outgoing::List message Sends LIST message to server.
-
#lusers(message) ⇒ Object
- message
-
Messages::Outgoing::Lusers message Sends LUSERS message to server.
-
#motd(message) ⇒ Object
- message
-
Messages::Outgoing::Motd message Sends MOTD message to server.
-
#names(message) ⇒ Object
- message
-
Messages::Outgoing::Names message Sends NAMES message to server.
-
#nick(message) ⇒ Object
- message
-
Messages::Outgoing::Nick message Sends NICK message to server.
-
#notice(message) ⇒ Object
- message
-
Messages::Outgoing::Notice message Sends NOTICE message to server.
-
#oper(message) ⇒ Object
- message
-
Messages::Outgoing::Oper message Sends Oper message to server.
-
#part(message) ⇒ Object
- message
-
Messages::Outgoing::Part message Sends PART message to server.
-
#pass(message) ⇒ Object
- message
-
Messages::Outgoing::Pass message Sends PASS message to server.
-
#ping(message) ⇒ Object
- message
-
Messages::Outgoing::Ping message Sends PING message to server.
-
#pong(message) ⇒ Object
- message
-
Messages::Outgoing::Pong message Sends PONG message to server.
-
#privmsg(message) ⇒ Object
- message
-
Messages::Outgoing::Privmsg message Sends PRIVMSG message to server.
-
#quit(message) ⇒ Object
- message
-
Messages::Outgoing::Quit message Sends QUIT message to server.
-
#raw(message) ⇒ Object
- message
-
Messages::Outoing::Raw message Send raw message to server.
-
#reconnect(message = nil) ⇒ Object
- message
-
Messages::Internal::Reconnect instructs bot to reconnect to IRC server.
-
#rehash(message) ⇒ Object
- message
-
Messages::Outgoing::Rehash message Sends REHASH message to server.
-
#reload ⇒ Object
Reload the bot (basically a restart).
-
#restart(message) ⇒ Object
- message
-
Messages::Outgoing::Restart message Sends RESTART message to server.
-
#run ⇒ Object
Run the bot.
-
#servlist(message) ⇒ Object
- message
-
Messages::Outgoing::ServList message Sends SERVLIST message to server.
-
#set_nick(message) ⇒ Object
- message
-
Messages::Internal::ChangeNick message Changes the bot’s nick to the given nick.
-
#shutdown ⇒ Object
Shut the bot down.
-
#squery(message) ⇒ Object
- message
-
Messages::Outgoing::Squery message Sends SQUERY message to server.
-
#squit(message) ⇒ Object
- message
-
Messages::Outgoing::Squit message Sends SQUIT message to server.
-
#stats(message) ⇒ Object
- message
-
Messages::Outgoing::Stats message Sends STATS message to server.
-
#status(message) ⇒ Object
- message
-
Messages::Internal::StatusRequest message Returns the current status of the bot.
-
#summon(message) ⇒ Object
- message
-
Messages::Outgoing::Summon message Sends SUMMON message to server.
-
#time(message) ⇒ Object
- message
-
Messages::Outgoing::Time message Sends TIME message to server.
-
#topic(message) ⇒ Object
- message
-
Messages::Outgoing::Topic message Sends TOPIC message to server.
-
#trace(message) ⇒ Object
- message
-
Messages::Outgoing::Trace message Sends TRACE message to server.
-
#unaway(message) ⇒ Object
- message
-
Messages::Outgoing::Unaway message Sends AWAY message to server.
-
#user(message) ⇒ Object
- message
-
Messages::Outgoing::User message Sends USER message to server.
-
#user_mode(message) ⇒ Object
- message
-
Messages::Outgoing::UserMode message Sends MODE message to server.
-
#userhost(message) ⇒ Object
- message
-
Messages::Outgoing::UserHost message Sends USERHOST message to server.
-
#users(message) ⇒ Object
- message
-
Messages::Outgoing::Users message Sends USERS message to server.
-
#version(message) ⇒ Object
- message
-
Messages::Outgoing::Version message Sends VERSION message to server.
- #wallops ⇒ Object
-
#who(message) ⇒ Object
- message
-
Messages::Outgoing::Who message Sends WHO message to server.
-
#whois(message) ⇒ Object
- message
-
Messages::Outgoing::Whois message Sends WHOIS message to server.
-
#whowas(message) ⇒ Object
- message
-
Messages::Outgoing::WhoWas message Sends WHOWAS message to server.
Constructor Details
#initialize ⇒ Bot
Create a Bot
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mod_spox/Bot.rb', line 37 def initialize unless(ModSpox.logto.nil?) logger = ::Logger.new(ModSpox.logto, 'daily') Logger.initialize(logger, ModSpox.loglevel) end clean_models @servers = Array.new @channels = Array.new @start_time = Time.now @pool = ActionPool::Pool.new(10, 100, 60, nil, logger) @pipeline = Pipeline.new(@pool) @timer = Timer.new(ActionTimer::Timer.new(@pool, logger), @pipeline) @config = BaseConfig.new(BotConfig[:userconfigpath]) @factory = MessageFactory.new(@pipeline, @pool) @socket = nil @plugin_manager = PluginManager.new(@pipeline) if(@config[:plugin_upgrade] == 'yes') @plugin_manager.upgrade_plugins Logger.info('Main bot thread is now sleeping for 10 seconds to allow upgrade to conclude') sleep(10) Logger.info('Main bot thread sleep completed. Continuing loading.') end @config[:plugin_upgrade] = 'no' @config.write_configuration @shutdown = false @socket = Sockets.new(self) @nick = nil @thread = Thread.current @lock = Mutex.new @waiter = ConditionVariable.new hook_pipeline end |
Instance Attribute Details
#dcc_sockets ⇒ Object (readonly)
DCC sockets
34 35 36 |
# File 'lib/mod_spox/Bot.rb', line 34 def dcc_sockets @dcc_sockets end |
#factory ⇒ Object (readonly)
message factory
31 32 33 |
# File 'lib/mod_spox/Bot.rb', line 31 def factory @factory end |
#pipeline ⇒ Object (readonly)
message pipeline
25 26 27 |
# File 'lib/mod_spox/Bot.rb', line 25 def pipeline @pipeline end |
#plugin_manager ⇒ Object (readonly)
plugin manager
28 29 30 |
# File 'lib/mod_spox/Bot.rb', line 28 def plugin_manager @plugin_manager end |
#pool ⇒ Object (readonly)
thread pool
22 23 24 |
# File 'lib/mod_spox/Bot.rb', line 22 def pool @pool end |
#timer ⇒ Object (readonly)
bot timer
19 20 21 |
# File 'lib/mod_spox/Bot.rb', line 19 def timer @timer end |
Instance Method Details
#admin(message) ⇒ Object
- message
-
Messages::Outgoing::Admin message
Sends ADMIN message to server
408 409 410 |
# File 'lib/mod_spox/Bot.rb', line 408 def admin() @socket << "ADMIN #{.target}" end |
#away(message) ⇒ Object
- message
-
Messages::Outgoing::Away message
Sends AWAY message to server
472 473 474 |
# File 'lib/mod_spox/Bot.rb', line 472 def away() @socket << "AWAY :#{.}" end |
#bot_connect(message) ⇒ Object
- message
-
Messages::Internal::EstablishConnection message
Initialize connection to IRC server
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/mod_spox/Bot.rb', line 113 def bot_connect() Logger.info("Received a connection command") begin @socket = Sockets.new(self) if @socket.nil? @socket.irc_connect(.server, .port) rescue Object => boom Logger.warn("Failed connection to server: #{boom}") @pipeline << Messages::Internal::ConnectionFailed.new(@socket.irc_socket.server, @socket.irc_socket.port) end end |
#bot_stats ⇒ Object
Returns status of the bot in a formatted string
150 151 152 153 154 155 156 |
# File 'lib/mod_spox/Bot.rb', line 150 def bot_stats return {:uptime => Helpers::format_seconds(Time.now - @start_time), :plugins => @plugin_manager.plugins.size, :socket_connect => @socket.irc_socket.connected_at, :sent => @socket.irc_socket.sent, :received => @socket.irc_socket.received} end |
#channel_mode(message) ⇒ Object
- message
-
Messages::Outgoing::ChannelMode message
Sends MODE message to server
281 282 283 284 285 286 287 |
# File 'lib/mod_spox/Bot.rb', line 281 def channel_mode() target = .target channel = .channel target = target.nick if target.is_a?(Models::Nick) channel = channel.name if channel.is_a?(Models::Channel) @socket << "MODE #{channel} #{.mode} #{target}" end |
#check_join(m) ⇒ Object
537 538 539 540 541 |
# File 'lib/mod_spox/Bot.rb', line 537 def check_join(m) if(m.nick.botnick) @channels << m.channel.name.downcase end end |
#check_part(m) ⇒ Object
543 544 545 546 547 |
# File 'lib/mod_spox/Bot.rb', line 543 def check_part(m) if(m.nick.botnick) @channels.delete(m.channel.name.downcase) end end |
#clear_timer(message) ⇒ Object
- message
-
Messages::Internal::TimerClear
Clear all actions from timer
192 193 194 |
# File 'lib/mod_spox/Bot.rb', line 192 def clear_timer() @timer.clear end |
#connect(message) ⇒ Object
- message
-
Messages::Outgoing::Connect message
Sends CONNECT message to server
396 397 398 |
# File 'lib/mod_spox/Bot.rb', line 396 def connect() @socket << "CONNECT #{.target_server} #{.port} #{.remote_server}" end |
#die(message) ⇒ Object
- message
-
Messages::Outgoing::Die message
Sends DIE message to server
490 491 492 |
# File 'lib/mod_spox/Bot.rb', line 490 def die() @socket << "DIE" end |
#disconnected(message) ⇒ Object
- message
-
Messages::Internal::Disconnected
Disconnect the bot from the IRC server
198 199 200 |
# File 'lib/mod_spox/Bot.rb', line 198 def disconnected() reload end |
#get_nick(message) ⇒ Object
- message
-
Messages::Internal::NickRequest
Sends the bot’s nick to plugins
216 217 218 |
# File 'lib/mod_spox/Bot.rb', line 216 def get_nick() @pipeline << Messages::Internal::NickResponse(.requester, @nick) end |
#halt(message = nil) ⇒ Object
Stop the bot
203 204 205 206 |
# File 'lib/mod_spox/Bot.rb', line 203 def halt(=nil) @shutdown = true reload end |
#hook_pipeline ⇒ Object
Adds hooks to pipeline for processing messages
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/mod_spox/Bot.rb', line 159 def hook_pipeline {:Outgoing_Admin => :admin, :Outgoing_Away => :away, :Outgoing_ChannelMode => :channel_mode, :Outgoing_Connect => :connect, :Outgoing_Die => :die, :Outgoing_Info => :info, :Outgoing_Invite => :invite, :Outgoing_Ison => :ison, :Outgoing_Join => :join, :Outgoing_Kick => :kick, :Outgoing_Kill => :kill, :Outgoing_Links => :links, :Outgoing_List => :list, :Outgoing_Lusers => :lusers, :Outgoing_Motd => :motd, :Outgoing_Names => :names, :Outgoing_Nick => :nick, :Outgoing_Notice => :notice, :Outgoing_Oper => :oper, :Outgoing_Part => :part, :Outgoing_Pass => :pass, :Outgoing_Ping => :ping, :Outgoing_Pong => :pong, :Outgoing_Privmsg => :privmsg, :Outgoing_Quit => :quit, :Outgoing_Rehash => :rehash, :Outgoing_ServList => :servlist, :Outgoing_Squery => :squery, :Outgoing_Squit => :squit, :Outgoing_Stats => :stats, :Outgoing_Summon => :summon, :Outgoing_Time => :time, :Outgoing_Topic => :topic, :Outgoing_Trace => :trace, :Outgoing_Unaway => :unaway, :Outgoing_User => :user, :Outgoing_UserHost => :userhost, :Outgoing_UserMode => :user_mode, :Outgoing_Users => :users, :Outgoing_Version => :version, :Outgoing_Who => :who, :Outgoing_WhoWas => :whowas, :Outgoing_Whois => :whois, :Internal_EstablishConnection => :bot_connect, :Internal_StatusRequest => :status, :Internal_ChangeNick => :set_nick, :Internal_NickRequest => :get_nick, :Internal_HaltBot => :halt, :Internal_Disconnected => :disconnected, :Internal_TimerClear => :clear_timer, :Outgoing_Raw => :raw, :Internal_Reconnect => :reconnect, :Incoming_Join => :check_join, :Incoming_Part => :check_part }.each_pair{ |type,method| @pipeline.hook(self, method, type) } end |
#info(message) ⇒ Object
- message
-
Messages::Outgoing::Info message
Sends INFO message to server
414 415 416 |
# File 'lib/mod_spox/Bot.rb', line 414 def info() @socket << "INFO #{.target}" end |
#invite(message) ⇒ Object
- message
-
Messages::Outgoing::Invite message
Sends INVITE message to server
312 313 314 315 316 317 |
# File 'lib/mod_spox/Bot.rb', line 312 def invite() okay_to_send(.channel) nick = .nick.is_a?(Models::Nick) ? .nick.nick : .nick channel = .channel.is_a?(Models::Channel) ? .channel.name : .channel @socket << "INVITE #{nick} #{channel}" end |
#ison(message) ⇒ Object
- message
-
Messages::Outgoing::Ison message
Sends ISON message to server
526 527 528 529 |
# File 'lib/mod_spox/Bot.rb', line 526 def ison() nick = .nick.is_a?(Models::Nick) ? .nick.nick : .nick @socket << "ISON #{nick}" end |
#join(message) ⇒ Object
- message
-
Messages::Outgoing::Join message
Sends JOIN message to server
267 268 269 270 |
# File 'lib/mod_spox/Bot.rb', line 267 def join() channel = .channel.is_a?(Models::Channel) ? .channel.name : .channel @socket << "JOIN #{channel} #{.key}" end |
#kick(message) ⇒ Object
- message
-
Messages::Outgoing::Kick message
Sends KICK message to server
321 322 323 324 325 326 |
# File 'lib/mod_spox/Bot.rb', line 321 def kick() okay_to_send(.channel) nick = .nick.is_a?(Models::Nick) ? .nick.nick : .nick channel = .channel.is_a?(Models::Channel) ? .channel.name : .channel @socket << "KICK #{channel} #{nick} :#{.reason}" end |
#kill(message) ⇒ Object
- message
-
Messages::Outgoing::Kill message
Sends KILL message to server
453 454 455 456 |
# File 'lib/mod_spox/Bot.rb', line 453 def kill() nick = .nick.is_a?(Models::Nick) ? .nick.nick : .nick @socket << "KILL #{nick} :#{.comment}" end |
#links(message) ⇒ Object
- message
-
Messages::Outgoing::Links message
Sends LINKS message to server
384 385 386 |
# File 'lib/mod_spox/Bot.rb', line 384 def links() @socket << "LIST #{.server} #{.mask}" end |
#list(message) ⇒ Object
- message
-
Messages::Outgoing::List message
Sends LIST message to server
305 306 307 308 |
# File 'lib/mod_spox/Bot.rb', line 305 def list() channel = .channel.is_a?(Models::Channel) ? .channel.name : .channel @socket << "LIST #{channel}" end |
#lusers(message) ⇒ Object
- message
-
Messages::Outgoing::Lusers message
Sends LUSERS message to server
365 366 367 |
# File 'lib/mod_spox/Bot.rb', line 365 def lusers() @socket << "LUSERS #{.mask} #{.target}" end |
#motd(message) ⇒ Object
- message
-
Messages::Outgoing::Motd message
Sends MOTD message to server
359 360 361 |
# File 'lib/mod_spox/Bot.rb', line 359 def motd() @socket << "MOTD #{.target}" end |
#names(message) ⇒ Object
- message
-
Messages::Outgoing::Names message
Sends NAMES message to server
298 299 300 301 |
# File 'lib/mod_spox/Bot.rb', line 298 def names() channel = .channel.is_a?(Models::Channel) ? .channel.name : .channel @socket << "NAMES #{channel} #{.target}" end |
#nick(message) ⇒ Object
- message
-
Messages::Outgoing::Nick message
Sends NICK message to server
228 229 230 231 |
# File 'lib/mod_spox/Bot.rb', line 228 def nick() nick = .nick.is_a?(Models::Nick) ? .nick.nick : .nick @socket << "NICK #{nick}" end |
#notice(message) ⇒ Object
- message
-
Messages::Outgoing::Notice message
Sends NOTICE message to server
350 351 352 353 354 355 |
# File 'lib/mod_spox/Bot.rb', line 350 def notice() okay_to_send(.target) target = .target.name if .target.is_a?(Models::Channel) target = .target.nick if .target.is_a?(Models::Nick) @socket << "NOTICE #{target} :#{}" end |
#oper(message) ⇒ Object
- message
-
Messages::Outgoing::Oper message
Sends Oper message to server
241 242 243 |
# File 'lib/mod_spox/Bot.rb', line 241 def oper() @socket << "OPER #{.name} #{.password}" end |
#part(message) ⇒ Object
- message
-
Messages::Outgoing::Part message
Sends PART message to server
274 275 276 277 |
# File 'lib/mod_spox/Bot.rb', line 274 def part() channel = .channel.is_a?(Models::Channel) ? .channel.name : .channel @socket << "PART #{channel} :#{.reason}" end |
#pass(message) ⇒ Object
- message
-
Messages::Outgoing::Pass message
Sends PASS message to server
222 223 224 |
# File 'lib/mod_spox/Bot.rb', line 222 def pass() @socket << "PASS #{.password}" end |
#ping(message) ⇒ Object
- message
-
Messages::Outgoing::Ping message
Sends PING message to server
460 461 462 |
# File 'lib/mod_spox/Bot.rb', line 460 def ping() @socket << "PING #{.}" end |
#pong(message) ⇒ Object
- message
-
Messages::Outgoing::Pong message
Sends PONG message to server
466 467 468 |
# File 'lib/mod_spox/Bot.rb', line 466 def pong() @socket << "PONG #{.server} #{.string.nil? ? '' : ":#{.string}"}" end |
#privmsg(message) ⇒ Object
- message
-
Messages::Outgoing::Privmsg message
Sends PRIVMSG message to server
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/mod_spox/Bot.rb', line 330 def privmsg() okay_to_send(.target) target = .target.name if .target.is_a?(Models::Channel) target = .target.nick if .target.is_a?(Models::Nick) target = .target unless target = ..is_a?(Array) ? . : [.] .each do |part| part.split("\n").each do |content| while(content.size > 400) output = content[0..400] content.slice!(0, 401) #(450, content.size) @socket.(target, "PRIVMSG #{target} :#{.is_ctcp? ? "\cA#{.ctcp_type} #{output}\cA" : output}") end @socket.(target, "PRIVMSG #{target} :#{.is_ctcp? ? "\cA#{.ctcp_type} #{content}\cA" : content}") end end end |
#quit(message) ⇒ Object
- message
-
Messages::Outgoing::Quit message
Sends QUIT message to server
255 256 257 |
# File 'lib/mod_spox/Bot.rb', line 255 def quit() @socket << "QUIT :#{.}" end |
#raw(message) ⇒ Object
- message
-
Messages::Outoing::Raw message
Send raw message to server
533 534 535 |
# File 'lib/mod_spox/Bot.rb', line 533 def raw() @socket << . end |
#reconnect(message = nil) ⇒ Object
- message
-
Messages::Internal::Reconnect
instructs bot to reconnect to IRC server
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/mod_spox/Bot.rb', line 126 def reconnect(=nil) begin @plugin_manager.reload_plugins @socket.irc_reconnect rescue Object => boom Logger.warn("Initial reconnect failed. (#{boom}) Starting timed reconnect process.") begin @socket.irc_reconnect rescue Object => boom Logger.warn("Failed to connect to server. Reason: #{boom}") Logger.warn("Will retry in 20 seconds") sleep(20) retry end end end |
#rehash(message) ⇒ Object
- message
-
Messages::Outgoing::Rehash message
Sends REHASH message to server
484 485 486 |
# File 'lib/mod_spox/Bot.rb', line 484 def rehash() @socket << "REHASH" end |
#reload ⇒ Object
Reload the bot (basically a restart)
105 106 107 108 109 |
# File 'lib/mod_spox/Bot.rb', line 105 def reload @lock.synchronize do @waiter.signal end end |
#restart(message) ⇒ Object
- message
-
Messages::Outgoing::Restart message
Sends RESTART message to server
496 497 498 |
# File 'lib/mod_spox/Bot.rb', line 496 def restart() @socket << "RESTART" end |
#run ⇒ Object
Run the bot
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/mod_spox/Bot.rb', line 71 def run trap('SIGTERM'){ Logger.warn("Caught SIGTERM"); halt } trap('SIGKILL'){ Logger.warn("Caught SIGKILL"); halt } trap('SIGINT'){ Logger.warn("Caught SIGINT"); halt } trap('SIGQUIT'){ Logger.warn("Caught SIGQUIT"); halt } until @shutdown do @pipeline << Messages::Internal::BotInitialized.new begin @lock.synchronize do Logger.info('Putting main execution thread to sleep until shutdown') @waiter.wait(@lock) Logger.info('Main execution thread has been restored.') end rescue Object => boom Logger.fatal("Caught exception: #{boom}") ensure shutdown end end end |
#servlist(message) ⇒ Object
- message
-
Messages::Outgoing::ServList message
Sends SERVLIST message to server
420 421 422 |
# File 'lib/mod_spox/Bot.rb', line 420 def servlist() @socket << "SERVLIST #{.mask} #{.type}" end |
#set_nick(message) ⇒ Object
- message
-
Messages::Internal::ChangeNick message
Changes the bot’s nick to the given nick
210 211 212 |
# File 'lib/mod_spox/Bot.rb', line 210 def set_nick() @nick = .new_nick end |
#shutdown ⇒ Object
Shut the bot down
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/mod_spox/Bot.rb', line 93 def shutdown @shutdown = true Logger.info('Shutdown sequence initiated') @plugin_manager.destroy_plugins @timer.stop @pipeline << Messages::Internal::Shutdown.new sleep(0.1) @socket.shutdown unless @socket.nil? clean_models end |
#squery(message) ⇒ Object
- message
-
Messages::Outgoing::Squery message
Sends SQUERY message to server
426 427 428 |
# File 'lib/mod_spox/Bot.rb', line 426 def squery() @socket << "SQUERY #{.service_name} #{.}" end |
#squit(message) ⇒ Object
- message
-
Messages::Outgoing::Squit message
Sends SQUIT message to server
261 262 263 |
# File 'lib/mod_spox/Bot.rb', line 261 def squit() @socket << "SQUIT #{.server} :#{.comment}" end |
#stats(message) ⇒ Object
- message
-
Messages::Outgoing::Stats message
Sends STATS message to server
377 378 379 380 |
# File 'lib/mod_spox/Bot.rb', line 377 def stats() raise Exceptions::InvalidValue.new('Query must be a single character') unless .query =~ /^[a-z]$/ @socket << "STATS #{.query} #{.target}" end |
#status(message) ⇒ Object
- message
-
Messages::Internal::StatusRequest message
Returns the current status of the bot
145 146 147 |
# File 'lib/mod_spox/Bot.rb', line 145 def status() @pipeline << Messages::Internal::StatusResponse.new(.requester, bot_stats) end |
#summon(message) ⇒ Object
- message
-
Messages::Outgoing::Summon message
Sends SUMMON message to server
502 503 504 505 506 |
# File 'lib/mod_spox/Bot.rb', line 502 def summon() nick = .nick.is_a?(Models::Nick) ? .nick.nick : .nick channel = .channel.is_a?(Models::Channel) ? .channel.name : .channel @socket << "SUMMON #{nick} #{.target} #{channel}" end |
#time(message) ⇒ Object
- message
-
Messages::Outgoing::Time message
Sends TIME message to server
390 391 392 |
# File 'lib/mod_spox/Bot.rb', line 390 def time() @socket << "TIME #{.target}" end |
#topic(message) ⇒ Object
- message
-
Messages::Outgoing::Topic message
Sends TOPIC message to server
291 292 293 294 |
# File 'lib/mod_spox/Bot.rb', line 291 def topic() channel = .channel.is_a?(Models::Channel) ? .channel.name : .channel @socket << "TOPIC #{channel} :#{.topic}" end |
#trace(message) ⇒ Object
- message
-
Messages::Outgoing::Trace message
Sends TRACE message to server
402 403 404 |
# File 'lib/mod_spox/Bot.rb', line 402 def trace() @socket << "TRACE #{.target}" end |
#unaway(message) ⇒ Object
- message
-
Messages::Outgoing::Unaway message
Sends AWAY message to server
478 479 480 |
# File 'lib/mod_spox/Bot.rb', line 478 def unaway() @socket << "AWAY" end |
#user(message) ⇒ Object
- message
-
Messages::Outgoing::User message
Sends USER message to server
235 236 237 |
# File 'lib/mod_spox/Bot.rb', line 235 def user() @socket << "USER #{.username} #{.mode} * :#{.real_name}" end |
#user_mode(message) ⇒ Object
- message
-
Messages::Outgoing::UserMode message
Sends MODE message to server
247 248 249 250 251 |
# File 'lib/mod_spox/Bot.rb', line 247 def user_mode() raise Exceptions::InvalidValue.new('Mode must be in the form of: [+-][a-z]+') unless .mode =~ /^[+\-][a-z]+$/ nick = .nick.is_a?(Models::Nick) ? .nick.nick : .nick @socket << "MODE #{nick} #{.mode}" end |
#userhost(message) ⇒ Object
- message
-
Messages::Outgoing::UserHost message
Sends USERHOST message to server
519 520 521 522 |
# File 'lib/mod_spox/Bot.rb', line 519 def userhost() nick = .nick.is_a?(Models::Nick) ? .nick.nick : .nick @socket << "USERHOST #{nick}" end |
#users(message) ⇒ Object
- message
-
Messages::Outgoing::Users message
Sends USERS message to server
510 511 512 |
# File 'lib/mod_spox/Bot.rb', line 510 def users() @socket << "USERS #{.target}" end |
#version(message) ⇒ Object
- message
-
Messages::Outgoing::Version message
Sends VERSION message to server
371 372 373 |
# File 'lib/mod_spox/Bot.rb', line 371 def version() @socket << "VERSION #{.target}" end |
#wallops ⇒ Object
514 515 |
# File 'lib/mod_spox/Bot.rb', line 514 def wallops end |
#who(message) ⇒ Object
- message
-
Messages::Outgoing::Who message
Sends WHO message to server
432 433 434 435 |
# File 'lib/mod_spox/Bot.rb', line 432 def who() o = .only_ops? ? 'o' : '' @socket.('*who', "WHO #{.mask} #{o}") end |