blob: 22b6491b58535e4aa0e1af31a7c5ba72bafffa66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
|