summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-11-15 17:52:09 -0500
committerJules Laplace <jules@okfoc.us>2016-11-15 17:52:09 -0500
commit7553643e39a16bacfb2ac6563a8558ac475042bc (patch)
tree599ed84b22fc2073073cbdc53e1ef60f3e94180b /lib
parent3f36129ec17fd0de2091b1a883ac6466a641de77 (diff)
link to socket workin
Diffstat (limited to 'lib')
-rw-r--r--lib/index.js10
-rw-r--r--lib/panda.js13
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/index.js b/lib/index.js
index 793581f..a9571f8 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -38,3 +38,13 @@ router.post("/_irc/post", function(req, res){
})
res.sendStatus(200)
})
+
+panda.watch(panda.channels[0], /(https?:\/\/[^\s]+)/g, function(data){
+ console.log(data)
+ data.match.forEach(function(match){
+ server.io.emit("link", {
+ nick: data.nick,
+ url: match,
+ })
+ })
+}) \ No newline at end of file
diff --git a/lib/panda.js b/lib/panda.js
index bb4b6ed..1757121 100644
--- a/lib/panda.js
+++ b/lib/panda.js
@@ -76,7 +76,7 @@ var message_queue = async.queue(function(task, done){
console.log("connecting..")
-client.addListener('registered', function (message) {
+client.addListener('registered', function () {
console.log("..registered!")
})
@@ -88,21 +88,22 @@ client.addListener('error', function (err) {
console.log("..error!", err)
})
-client.addListener('join', function (channel, nick, message) {
+client.addListener('join', function (channel, nick) {
console.log("* " + nick + " joined " + channel)
if (nick == 'panda' && channel == '#sally') {
panda.login()
}
})
-client.addListener('message', function (nick, to, text, message) {
+client.addListener('message', function (nick, to, text) {
watchers.forEach(function(watcher){
+ console.log(nick, to, text, watcher)
if (to === watcher.channel) {
- var match = watcher.regexp.match(text)
+ var match = text.match(watcher.regexp)
if (match) {
- cb({
+ watcher.cb({
channel: to,
nick: nick,
- message: message,
+ text: text,
match: match,
})
}