summaryrefslogtreecommitdiffstats
path: root/webchat
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2013-11-11 18:05:25 +0100
committerlassulus <lassulus@googlemail.com>2013-11-11 18:05:25 +0100
commitbc0a0e1ec282bcfc7aa2ef9eb444b2403d0c7199 (patch)
tree5702abe66d226370e58f721679b2253760fd7737 /webchat
parentd577b700aa39c6dba270cbc9c11f3777866d4a69 (diff)
webchat: refactor into serverCommands.js
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