Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to issues which led the module to not work properly #1

Merged
merged 1 commit into from
Jun 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions assocfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ exports.match = function(event, commandPrefix) {
var s = event.body.toLowerCase();
for (var assoc in exports.config[event.thread_id]) {
if (s.indexOf(assoc.toLowerCase()) !== -1) {
if (!event.__assocateCmd) {
event.__associatedCmd = {
if (!event.__associateCmd) {
event.__associateCmd = {
thread: event.thread_id,
responses: []
};
Expand All @@ -22,10 +22,12 @@ exports.match = function(event, commandPrefix) {

var toggleAssociation = function(thread, hook, text) {
hook = hook.toLowerCase();
if (exports.config[thread] && exports.config[thread][hook] && !text) {
delete exports.config[thread][hook];
return false;
}
if (!text) {
if (exports.config[thread] && exports.config[thread][hook]) {
delete exports.config[thread][hook];
}
return false;
}

if (!exports.config[thread]) {
exports.config[thread] = {};
Expand Down Expand Up @@ -60,8 +62,8 @@ exports.run = function(api, event) {
}

if (!isCommand && event.__associateCmd) {
for (var i = 0; i < event.__assocateCmd.responses.length; i++) {
api.sendImage("file", event.__associatedCmd.responses[i], event.thread_id);
for (var i = 0; i < event.__associateCmd.responses.length; i++) {
api.sendImage("file", event.__associateCmd.responses[i], "", event.thread_id);
}
return;
}
Expand All @@ -70,6 +72,6 @@ exports.run = function(api, event) {
return api.sendMessage('Invalid arguments, use /help assocfile for help.', event.thread_id);
}

toggleAssociation(event.thread_id, event.arguments[1], event.arguments[3]);
toggleAssociation(event.thread_id, event.arguments[1], event.arguments[2]);
api.sendMessage('Association of file changed.', event.thread_id);
};
2 changes: 1 addition & 1 deletion kassy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "assocfile",
"version": 1.1,
"version": 1.2,
"startup": "assocfile.js",
"help": [
["{{commandPrefix}}assocfile \"<hook>\" \"<file_name>\" or clear", "Associate and disassociate a file with a phrase.", "Associate and disassociate a file like image, video or audio (from ~\\files directory) with a phrase (so that a file is sent on a given phrase in chat)."]
Expand Down