Skip to content

Commit

Permalink
StatusOutput: MAP の応答に、割合を入れた
Browse files Browse the repository at this point in the history
  • Loading branch information
koi-chan committed Jul 11, 2015
1 parent 5549844 commit 6e86548
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/rgrb/plugin/status_output/irc_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# vim: fileencoding=utf-8

require 'cinch'
require 'socket'
require 'pp'

module RGRB
Expand All @@ -14,7 +13,9 @@ class IrcAdapter

set(plugin_name: 'StatusOutput')
timer(5, method: :request_map)
# match(/map/, method: :request_map)
timer(5, method: :request_lusers)
match(/map/, method: :request_map)
match(/lusers/, method: :request_lusers)

# MAP コマンドの応答 (charybdis)
listen_to(:'015', method: :map)
Expand All @@ -41,25 +42,21 @@ def initialize(*args)
}
end

def request_map
host = 'irc.cre.jp'
port = 6666
p 'Socket Open'
daemon_socket = TCPSocket.open(host, port)
daemon_socket.write("nick RGRB-requestmap\r\n")
daemon_socket.write("user RGRB 0 0 :\r\n")
daemon_socket.write("map\r\n")
daemon_socket.write("quit\r\n")
daemon_socket.close
p 'Socket Close'
def request_map(m)
bot.irc.send('MAP')
end

def request_lusers(m)
bot.irc.send('LUSERS')
end

def map(m)
#get_time = m.time
m.params[1].match(
%r{[\|`\- ]*([\w\.\-]+)\[\d\d\w\] -+ \| Users:\s+(\d+)}
%r{[\|`\- ]*([\w\.\-]+)\[\d\d\w\] -+ \| Users:\s+(\d+) \(\s*(\d+\.\d)%\)}
) { |md|
print("ircMap_#{@servername[md[1]]}.value #{md[2]}\n")
print("ircMapPercent_#{@servername[md[1]]}.value #{md[3]}\n")
}
end

Expand Down

0 comments on commit 6e86548

Please sign in to comment.