Commit 27177bb5 authored by Cool Fire's avatar Cool Fire

Add socketmessage plugin

parent 42e1ccac
Pipeline #305 failed with stages
in 4 minutes and 42 seconds
#!/usr/bin/env ruby
# Plugin to get
class Socketmessage
require 'socket'
require 'json'
# This method is called when the plugin is first loaded
def initialize( status, config, output, irc, timer )
@status = status
@config = config
@output = output
@irc = irc
@timer = timer
@server = TCPServer.open('localhost', 2000)
t = Thread.new{ startserver }
end
# Close server
def unload
@server.close
return true
end
def help( nick, user, host, from, msg, arguments, con )
line = 'This plugin gets messages from a local socket. No interactive commands available'
if( con )
@output.c( line + "\n" )
else
@irc.notice( nick, line )
end
end
private
def startserver
loop do
client = @server.accept
input = JSON.parse client.gets
@irc.message( input['dest'], input['message'] )
client.close
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment