Skip to content

Instantly share code, notes, and snippets.

@freaktechnik
Last active September 13, 2016 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freaktechnik/f9ba42c683551124540853eb8e749afc to your computer and use it in GitHub Desktop.
Save freaktechnik/f9ba42c683551124540853eb8e749afc to your computer and use it in GitHub Desktop.
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* This implements server-timestamps for IRC.
* http://ircv3.net/specs/extensions/server-time-3.2.html
*/
this.EXPORTED_SYMBOLS = ["capServerTime", "tagServerTime"];
Cu.import("resource:///modules/ircHandlers.jsm");
var tagServerTime = {
name: "server-time Tags",
priority: ircHandlers.DEFAULT_PRIORITY,
isEnabled: () => true,
commands: {
"time": function(aMsg) {
aMsg.message.time = Math.floor(Date.parse(aMsg.tagValue) / 1000);
}
}
};
var capServerTime = {
name: "server-time CAP",
priority: ircHandlers.DEFAULT_PRIORITY,
isEnabled: () => true,
commands: {
"server-time": function(aMessage) {
if(aMessage.cap.subcommand == "LS") {
this.sendMessage("CAP", ["REQ", "server-time"]);
}
return true;
},
"znc.in/server-time-iso": function(aMessage) {
if(aMessage.cap.subcommand == "LS") {
this.sendMessage("CAP", ["REQ", "znc.in/server-time-iso"]);
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment