summaryrefslogtreecommitdiffstats
path: root/webchat
diff options
context:
space:
mode:
Diffstat (limited to 'webchat')
-rw-r--r--webchat/index.js24
-rw-r--r--webchat/serverCommands.js26
2 files changed, 27 insertions, 23 deletions
diff --git a/webchat/index.js b/webchat/index.js
index cf045912..8a669d84 100644
--- a/webchat/index.js
+++ b/webchat/index.js
@@ -4,6 +4,7 @@ var http = require('https');
var sockjs = require('sockjs');
var connect = require('connect');
var irc = require('irc');
+var serverCommands = require('./serverCommands.js');
var serverstate = {
connected = false,
@@ -24,29 +25,6 @@ clients.notifyAll = function (method, params) {
}
-var serverCommands = {};
-
-serverCommands.say = function (settings, params) {
- var nick = settings.nick
- var message = params.msg
- params.nick = nick
- irc_client.say("#krebs", nick + ' → ' + message);
- return clients.notifyAll('message', params)
-// return clients.broadcast({ method: 'message', params: params })
-
-}
-
-serverCommands.nick = function (settings, params) {
- var oldnick = settings.nick || settings.conn.remoteAddress
- var newnick = params.nick
- settings.nick = newnick
- return clients.notifyAll('nickchange', { nick: oldnick, newnick: newnick });
-// return clients.broadcast({ method: 'nickchange', params: { nick: oldnick, newnick: newnick }})
-}
-
-serverCommands.badcommand = function (settings, params) {
- settings.conn.write(JSON.stringify({ method: 'usererror', params: { message: 'bad command' }}))
-}
var irc_reconnect = function() { //reconnt to irc
console.log("reconnecting due to pingtimeout");
diff --git a/webchat/serverCommands.js b/webchat/serverCommands.js
new file mode 100644
index 00000000..05c9ea0e
--- /dev/null
+++ b/webchat/serverCommands.js
@@ -0,0 +1,26 @@
+
+
+var serverCommands = {};
+serverCommands.say = function (settings, params) {
+ var nick = settings.nick
+ var message = params.msg
+ params.nick = nick
+ irc_client.say("#krebs", nick + ' → ' + message);
+ return clients.notifyAll('message', params)
+// return clients.broadcast({ method: 'message', params: params })
+
+}
+
+serverCommands.nick = function (settings, params) {
+ var oldnick = settings.nick || settings.conn.remoteAddress
+ var newnick = params.nick
+ settings.nick = newnick
+ return clients.notifyAll('nickchange', { nick: oldnick, newnick: newnick });
+// return clients.broadcast({ method: 'nickchange', params: { nick: oldnick, newnick: newnick }})
+}
+
+serverCommands.badcommand = function (settings, params) {
+ settings.conn.write(JSON.stringify({ method: 'usererror', params: { message: 'bad command' }}))
+}
+
+module.exports = serverCommands