diff options
author | 2015-03-07 23:28:29 +0100 | |
---|---|---|
committer | 2015-03-07 23:28:29 +0100 | |
commit | d9683751a0eadfa6e7b3736d361a29acedfa3a57 (patch) | |
tree | 9f3656e2fcad6ad95fc39f61d4c8bb93aae75c52 /plugins | |
download | udp2irc-d9683751a0eadfa6e7b3736d361a29acedfa3a57.tar.gz udp2irc-d9683751a0eadfa6e7b3736d361a29acedfa3a57.tar.bz2 udp2irc-d9683751a0eadfa6e7b3736d361a29acedfa3a57.zip |
Initial commit
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/message.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/message.rb b/plugins/message.rb new file mode 100644 index 0000000..22b6491 --- /dev/null +++ b/plugins/message.rb @@ -0,0 +1,30 @@ +require 'socket' + +class Listener + def initialize(bot) + @bot = bot + end + + def start + @server = UDPSocket.new + @server.bind(INGEST_ADDR, INGEST_PORT) + + while true do + msg, sender = @server.recvfrom(1024) + @bot.handlers.dispatch(:udpmessage, nil, msg) + end + end +end + +class MessagePlugin + include Cinch::Plugin + + listen_to :udpmessage + def listen(m, message) + FILTERS.each do |filter| + return if message.match filter + end + + Channel(IRC_CHANNEL).send message + end +end
\ No newline at end of file |