Skip to content

Commit dce682d

Browse files
committed
Bugfixes, etc.
1 parent ed438a1 commit dce682d

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

aucgbot.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/* globals: entities, aucgbot, encodeUTF8, decodeUTF8, writeln, println */
77
"use strict";
88
var net = require("net"),
9+
url = require("url"),
910
util = require("util"),
1011
fs = require("fs"),
1112
http = require("httpsync"),
@@ -462,7 +463,7 @@ aucgbot.checkFlood = function checkFlood(e) {
462463
}
463464
if ((diff ? conn.flood_lines[nick] : conn.flood_lines) >= this.prefs.flood.lines && now - (diff ? conn.flood_lastTime[nick] : conn.flood_lastTime) <= this.prefs.flood.secs * 1000) {
464465
var kb = this.okToKick(e);
465-
if (difF)
466+
if (diff)
466467
conn.flood_lastTime[nick] = now;
467468
else
468469
conn.flood_lastTime = now;
@@ -578,7 +579,7 @@ aucgbot.parseCmd = function parseCmd(e) {
578579
if (cmd.substr(0,4) == "cmd_") {
579580
cmd = cmd.substr(4);
580581
}
581-
console.log(cmd, require('util').inspect(e));
582+
// console.log(cmd, require('util').inspect(e));
582583
this.modMethod("parseCmd", arguments) || this.modMethod("cmd_" + cmd, arguments);
583584
} catch (ex) {
584585
e.notice("Oops, I encountered an error.", ex);
@@ -609,15 +610,15 @@ aucgbot.getHTTP = function getHTTP(uri, modname, modver, headers) {
609610
if (modver)
610611
useragent += "/" + modver;
611612
}
612-
headers["User-Agent"] = useragent;
613613
var req = http.request({
614614
"url": uri,
615615
"method": "GET",
616-
"useragent": useragent,
617-
"headers": headers
616+
"headers": headers,
617+
"useragent": useragent
618618
});
619619
var res = req.end();
620-
if (res.status && res.status >= 300) {
620+
if (res.statusCode && res.statusCode >= 300) {
621+
console.log("the stuff", res.statusCode, res.data.toString());
621622
throw new this.HTTPError(res, res.data.toString());
622623
}
623624
return res.data.toString();
@@ -693,14 +694,12 @@ aucgbot.loadModule = function loadModule(id) {
693694
* @return {boolean} Whether to stop processing the event.
694695
*/
695696
aucgbot.modMethod = function modMethod(id, args) {
696-
console.log(require('util').inspect(args));
697697
if (args != null && typeof args.length !== "number")
698698
args = Array.slice(arguments, 1);
699699
try {
700700
for (var m in this.modules) {
701701
if (this.modules.hasOwnProperty(m)) {
702702
module = this.modules[m];
703-
console.log('try and run: ' + id + ' from ' + m);
704703
if (typeof module === "object" && module && module.hasOwnProperty(id)) {
705704
let method = module[id];
706705
if (typeof method === "function" && method.apply(module, args))

bom.jsm

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,46 @@
33
* License, v. 2.0. If a copy of the MPL was not distributed with this
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
55
/*global Record: false, module: false */
6+
(function(bom){
7+
bom.version = "0.9.3 (2014-01-21)";
68

7-
module.version = "0.9.3 (2014-01-21)";
8-
9-
module.loadStateNames = function loadStateNames(state) {
9+
bom.loadStateNames = function loadStateNames(state) {
1010
var names = new Record();
1111
names.readINI(system.cwd + "/bom_names.ini", state);
1212
return names;
1313
};
1414

15-
module.idToFwoJsonUrl = function idToFwoJsonUrl(id) {
15+
bom.idToFwoJsonUrl = function idToFwoJsonUrl(id) {
1616
// BoM's JSON seems to be a bit much for JSDB to handle correctly, i.e. not load entirely
1717
var regionId = id.slice(0, id.indexOf("."));
1818
return "http://www.bom.gov.au/fwo/ID{0}/ID{1}.json".format(regionId, id);
1919
};
2020

21-
module.idToMinJsonUrl = function idToMinJsonUrl(id) {
21+
bom.idToMinJsonUrl = function idToMinJsonUrl(id) {
2222
return String.format("http://vovo.id.au/scripts/bommin.php?id={0}&wmo={1}", id.split("."));
2323
};
2424

25-
module.fullNameToName = function fullNameToName(name) {
25+
bom.fullNameToName = function fullNameToName(name) {
2626
var station = name.split(" "), state = station.pop();
2727
return [station.join(" ").replace(/,$/, ""), state];
2828
}
2929

30-
module.nameToId = function nameToId(station, state) {
30+
bom.nameToId = function nameToId(station, state) {
3131
var names = this.loadStateNames(state);
3232
return names.get(station);
3333
};
3434

35-
module.cmd_bom_id2fwo = function cmd_bom_id2fwo(e) {
35+
bom.cmd_bom_id2fwo = function cmd_bom_id2fwo(e) {
3636
e.notice(this.idToFwoJsonUrl(e.args));
3737
return true;
3838
};
3939

40-
module.cmd_bom_name2id = function cmd_bom_name2id(e) {
40+
bom.cmd_bom_name2id = function cmd_bom_name2id(e) {
4141
e.reply(this.nameToId.apply(this, this.fullNameToName(e.args)));
4242
return true;
4343
};
4444

45-
module.cmd_bom = function cmd_bom(e) {
45+
bom.cmd_bom = function cmd_bom(e) {
4646
var args = e.args;
4747
if (!args) {
4848
e.reply(this.cmd_bom.help);
@@ -100,4 +100,5 @@ module.cmd_bom = function cmd_bom(e) {
100100
e.nreply("Current weather for", data.name + ",", state.toUpperCase(), "from the Bureau of Meteorology (as of", data.local_date_time + "):", res.join(" - "));
101101
return true;
102102
};
103-
module.cmd_bom.help = "Get current weather conditions from the Bureau of Meteorology. Usage: bom <station> <state>";
103+
bom.cmd_bom.help = "Get current weather conditions from the Bureau of Meteorology. Usage: bom <station> <state>";
104+
})(module.exports);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"html-entities": "^1.1.1",
77
"httpsync": "0.0.8",
88
"moment": "^2.8.3",
9-
"moment-timezone": "^0.2.2"
9+
"moment-timezone": "^0.2.2",
10+
"synchronize": "^0.9.9"
1011
},
1112
"scripts": {
1213
"start": "node --harmony --use-strict start-aucgbot"

start-aucgbot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ for (let s = readln().trim().split(","); m=s.shift();) {
2424
{
2525
let servers = [
2626
/*["Hostname", "Port", "Nickname", "Ident", "Pass", "Channels", "SASL user", "SASL pass"]*/
27-
["chat.freenode.net", "6667", "aucgbot", "aucgbot", "", "", "", ""]
27+
["chat.freenode.net", "6667", "treebot", "aucgbot", "", "##hypnotoad", "PaperBag", "uniqueradioactivelolly"]
2828
];
2929

3030
aucgbot.start.apply(aucgbot, servers);

0 commit comments

Comments
 (0)