Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Add private messages setting for #22
Browse files Browse the repository at this point in the history
  • Loading branch information
Efreak committed Apr 6, 2015
1 parent 2254d2d commit 5cf9738
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/triggers/statusTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ if (typeof localStorage === "undefined" || localStorage === null) {
var LocalStorage = require("node-localstorage").LocalStorage;
}
/*
Trigger that sends a status message in public to anyone joining the chat. Use rooms:[] in options to limit it to one groupchat.
Trigger that sends a status message in public or private to anyone joining the chat. Use rooms:[] in options to limit it to one groupchat.
options:
admin = string - steamid64 of those allowed to change the status message. If not defined, anyone can change it.
command = string - command to change the message. Defaults to !status
locate = string - where to store the statuses on disk. Defaults to ./BOTNAME/StatusTrigger/TRIGGERNAME
if you need storages to be shared, set them to `myBot.username + "/StatusTrigger"` or some such.
public = bool - send the message to the joining user, or to the chat? To the chat if true (default), to the user if false.
*/

var StatusTrigger = function() {
Expand All @@ -25,6 +26,7 @@ exports.create = function(name, chatBot, options) {
trigger.respectsMute = false;
trigger.options.command = trigger.options.command || "!status";
trigger.options.location = options.location || (process.cwd()+"/"+chatBot.username + "/"+type);
trigger.options.public = options.public || true;
try{ //node-localstorage doesn't make parent directories. BOO. I refuse to look up how to do this properly, we'll just require mkdirp instead.
trigger.store = new LocalStorage(trigger.options.location);
}catch(err){
Expand All @@ -48,7 +50,7 @@ StatusTrigger.prototype._respondToChatMessage = function(roomId, chatterId, mess

StatusTrigger.prototype._respondToEnteredMessage = function(roomId, userId) {
if(this.store.getItem(roomId)) {
this._sendMessageAfterDelay(roomId, this.store.getItem(roomId));
this._sendMessageAfterDelay((options.public ? roomId : userId), this.store.getItem(roomId));
return true;
}
return false;
Expand Down

0 comments on commit 5cf9738

Please sign in to comment.