From 03326d7d785a77eedbac6cd8bc771b110e4eefdf Mon Sep 17 00:00:00 2001 From: Georg Date: Tue, 24 Aug 2021 21:30:13 +0200 Subject: [PATCH] Init Signed-off-by: Georg --- README.md | 11 + idose/idose.js | 129 +++ tripsit/INSTALL | 1 + tripsit/api.js | 565 +++++++++++++ tripsit/combo.json | 755 +++++++++++++++++ tripsit/config.json | 6 + tripsit/pages.js | 184 ++++ tripsit/strings.json | 53 ++ tripsit/tripsit | 1 + tripsit/tripsit.js | 1175 ++++++++++++++++++++++++++ tripsit/usage.json | 7 + tripsit/views/factsheet.jade | 32 + tripsit/views/fs_list.jade | 48 ++ tripsit/views/tripsit/factsheet.jade | 32 + tripsit/views/tripsit/fs_list.jade | 48 ++ 15 files changed, 3047 insertions(+) create mode 100644 README.md create mode 100644 idose/idose.js create mode 100644 tripsit/INSTALL create mode 100644 tripsit/api.js create mode 100644 tripsit/combo.json create mode 100644 tripsit/config.json create mode 100644 tripsit/pages.js create mode 100644 tripsit/strings.json create mode 160000 tripsit/tripsit create mode 100644 tripsit/tripsit.js create mode 100644 tripsit/usage.json create mode 100644 tripsit/views/factsheet.jade create mode 100644 tripsit/views/fs_list.jade create mode 100644 tripsit/views/tripsit/factsheet.jade create mode 100644 tripsit/views/tripsit/fs_list.jade diff --git a/README.md b/README.md new file mode 100644 index 0000000..68420a5 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +### TripSit related modules for dbot - revived + +This houses forks of dbot modules specific to the TripSit IRC network. + +The following issues have been resolved: + +- Replaced alsuti uploader with a generic, self-hosted, https (curl) endpoint for dose log uploads + +### Credits + +All credits go to https://github.com/reality/ - Thank you for having made dbot and these modules possible. It served countless of users well over several years - and albeit bundled with the occasional complaints and bugs, it never left its place in many, many hearts. diff --git a/idose/idose.js b/idose/idose.js new file mode 100644 index 0000000..4aee480 --- /dev/null +++ b/idose/idose.js @@ -0,0 +1,129 @@ +/** + * Module Name: idose + * Description: dose recording + */ + +var moment = require('moment-timezone'), + _ = require('underscore')._, + fs = require('fs'), + exec = require('child_process').exec; + +var idose = function(dbot) { + var self = this; + + this.api = { + // Save new dose entry + 'saveLastDose': function(user, drug, dose, callback) { + var lDose = { + 'time': Date.now(), + 'drug': drug, + 'dose': dose + }; + + if(!_.has(dbot.db.idose, user) || !_.isArray(dbot.db.idose[user])) { + dbot.db.idose[user] = []; + } + dbot.db.idose[user].push(lDose); + + callback(lDose); + }, + + // Retrieve user's last dose, by id + 'getLastDose': function(user, callback) { + callback(_.last(dbot.db.idose[user.id])); + }, + + 'alsutu': function(user, tz) { // TODO: this belongs in its own module and is generally hax, bad + tz = tz || 'Europe/London'; + var out = 'drug\tdose\ttime'; + + _.each(dbot.db.idose[user.id], function(entry) { + out += '\n'+entry.drug+'\t'+entry.dose+'\t'+moment(entry.time).tz(tz).format('HH:mm:ss DD/MM/YYYY'); + }); + + fs.writeFileSync('/tmp/'+user.id+'dd.txt', out); + + function puts(error, stdout, stderr) { + var res = stdout.split('\n'); + dbot.say(user.id.split('.')[1], user.primaryNick, 'New idose log at: ' + res); + } + exec("/bin/curl -sT "+"/tmp/"+user.id+'dd.txt '+"https://hugz.io/"+randomString(12, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), puts); + } + }; + + this.commands = { + 'idose': function(event) { + var dose = event.params[1] + dName = event.params[2], + roa = event.params[3]; + + if(roa) { + roa = capitalise(roa); + } + + dbot.api.tripsit.getDrug(dName, function(drug) { + if(drug) { + self.api.saveLastDose(event.rUser.id, dName, dose, function(lDose) { + dName = drug.pretty_name; + var tz = event.rProfile.timezone || 'Europe/London'; + var out = 'Dosed ' + dose + ' ' + dName + ' at ' + moment(lDose.time).tz(tz).format('HH:mm:ss on DD/MM/YYYY'); + if(roa) { + out += ' via ' + roa; + } + out += '.'; + + if(_.has(drug, 'formatted_onset')) { + if(_.has(drug.formatted_onset, roa)) { + out += ' You should start to feel effects ' + drug.formatted_onset[roa] + ' ' + (drug.formatted_onset._unit ? (drug.formatted_onset._unit + ' ') : '') + 'from now.' + } else if(_.has(drug.formatted_onset, 'value')) { + out += ' You should start to feel effects ' + drug.formatted_onset.value + ' ' + (drug.formatted_onset._unit ? (drug.formatted_onset._unit + ' ') : '') + 'from now.' + } + } + out += ' (BTW, you can run ~set upidose true to have tripbot upload an encrypted version of your dose history to you upon updates).' + event.reply(out); + + if(event.rProfile.upidose === "true") { + self.api.alsutu(event.rUser, tz); + } + }); + } else { + event.reply("I have not heard of that drug before mate, take a look at the list on http://drugs.tripsit.me/"); + } + }); + }, + + 'lastdose': function(event) { + this.api.getLastDose(event.rUser, function(lDose) { + if(lDose) { + var tz = event.rProfile.timezone || 'Europe/London'; + var out = 'You last dosed ' + lDose.dose + ' of ' + lDose.drug + + ' ' + moment(lDose.time).toNow(true) + ' ago (' + + moment(lDose.time).tz(tz).format('HH:mm:ss on DD/MM/YYYY') + + ' ' + tz + ').'; + event.reply(out); + } else { + event.reply('No last dose recorded'); + } + }); + } + } + + this.onLoad = function() { + if(!dbot.db.idose) { + dbot.db.idose = {}; + } + } +}; + +exports.fetch = function(dbot) { + return new idose(dbot); +}; + +function capitalise(string) { + return string.charAt(0).toUpperCase() + string.slice(1); +} +function randomString(length, chars) { + var result = ''; + for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)]; + return result; +} diff --git a/tripsit/INSTALL b/tripsit/INSTALL new file mode 100644 index 0000000..69c0873 --- /dev/null +++ b/tripsit/INSTALL @@ -0,0 +1 @@ +Move views/tripsit to dbot /views/tripsit diff --git a/tripsit/api.js b/tripsit/api.js new file mode 100644 index 0000000..0b35f7b --- /dev/null +++ b/tripsit/api.js @@ -0,0 +1,565 @@ +var _ = require('underscore'), + databank = require('databank'), + async = require('async'); + +var api = function(dbot) { + var api = { + 'getDrugCategory': function(name, callback) { + name = name.toLowerCase(); + this.db.read('drug_categories', name, function(err, cat) { + callback(cat); + }); + }, + + 'getIRCFormattedDrug': function(name, property, callback) { + this.api.getDrug(name, function(drug) { + if(drug && !_.has(drug, 'err')) { + if(_.has(drug, 'links') && _.has(drug.links, 'experiences')) { + drug.properties.experiences = drug.links.experiences; + } + if(!_.isUndefined(property)) { + if(_.has(drug.properties, property)) { + var info = drug.properties[property]; + + // TODO: Remove magic vars and move to formatProperty API func + if(property == 'dose') { + info = info.replace(/Threshold:/gi, "\u00032Threshold\u000f:"); + info = info.replace(/Light:/gi, "\u00033Light\u000f:"); + info = info.replace(/Common:/gi, "\u00037Common\u000f:"); + info = info.replace(/Strong:/gi, "\u00035Strong\u000f:"); + info = info.replace(/Heavy:/gi, "\u00034Heavy\u000f:"); + } + + if(property == 'aliases') info = info.join(', '); + + callback(name + ' ' + property + ': ' + info); + } else { + callback(name + ' Info: ' + _.keys(drug.properties).join(', ') + ' - http://drugs.tripsit.me/' + drug.name); + } + } else { + callback(name + ' Info: ' + _.keys(drug.properties).join(', ') + ' - http://drugs.tripsit.me/' + drug.name); + } + } else { + callback(null); + } + }); + + }, + + 'getInteraction': function(drugAName, drugBName, callback) { + drugAName = drugAName.toLowerCase(); + drugBName = drugBName.toLowerCase(); + + if(drugAName == 'ssri' || drugAName == 'snri' || drugAName == 'snris') { + drugAName = 'ssris'; + } else if(drugAName == 'maoi') { + drugAName = 'maois'; + } + + if(drugBName == 'ssri' || drugBName == 'snri' || drugBName == 'snris') { + drugBName = 'ssris'; + } else if(drugBName == 'maoi') { + drugBName = 'maois'; + } + + this.api.getDrug(drugAName, function(drugA) { + if(!_.has(drugA, 'err') || _.has(this.combos, drugAName)) { + this.api.getDrug(drugBName, function(drugB) { + if(!_.has(drugB, 'err') || _.has(this.combos, drugBName)) { + var safetyCategoryA = null, + safetyCategoryB = null; + + if(_.has(this.combos, drugAName)) { + safetyCategoryA = drugAName; + } else if(_.has(this.combos, drugA.name)) { + safetyCategoryA = drugA.name; + } else if(drugA.name.match(/^do.$/i)) { + safetyCategoryA = 'dox'; + } else if(drugA.name.match(/^2c-.$/i)) { + safetyCategoryA = '2c-x'; + } else if(drugA.name.match(/^25.-nbome/i)) { + safetyCategoryA = 'nbomes'; + } else if(drugA.name.match(/^5-meo-..t$/i)) { + safetyCategoryA = '5-meo-xxt'; + } else if(_.include(drugA.categories, 'benzodiazepine')) { + safetyCategoryA = 'benzodiazepines'; + } else if(_.include(drugA.categories, 'opioid')) { + safetyCategoryA = 'opioids'; + } else if(_.include(drugB.categories, 'benzo')) { + safetyCategoryB = 'benzos'; + } else if(_.include(drugA.categories, 'stimulant')) { + safetyCategoryA = 'amphetamines'; + } else if(drugA.name == 'ghb' || drugA.name == 'gbl') { + safetyCategoryA = 'ghb/gbl'; + } + if(_.has(this.combos, drugBName)) { + safetyCategoryB = drugBName; + } else if(_.has(this.combos, drugB.name)) { + safetyCategoryB = drugB.name; + } else if(drugB.name.match(/^do.$/i)) { + safetyCategoryB = 'dox'; + } else if(drugB.name.match(/^2c-.$/i)) { + safetyCategoryB = '2c-x'; + } else if(drugB.name.match(/^25.-nbome/i)) { + safetyCategoryB = 'nbomes'; + } else if(drugB.name.match(/^5-meo-..t$/i)) { + safetyCategoryB = '5-meo-xxt'; + } else if(_.include(drugB.categories, 'benzodiazepine')) { + safetyCategoryB = 'benzodiazepines'; + } else if(_.include(drugB.categories, 'opioid')) { + safetyCategoryB = 'opioids'; + } else if(_.include(drugB.categories, 'benzo')) { + safetyCategoryB = 'benzos'; + } else if(_.include(drugB.categories, 'stimulant')) { + safetyCategoryB = 'amphetamines'; + } else if(drugB.name == 'ghb' || drugB.name == 'gbl') { + safetyCategoryB = 'ghb/gbl'; + } + + if(safetyCategoryA && safetyCategoryB) { + if(safetyCategoryA != safetyCategoryB) { + var result = _.clone(this.combos[safetyCategoryA][safetyCategoryB]); + result['interactionCategoryA'] = safetyCategoryA; + result['interactionCategoryB'] = safetyCategoryB; + return callback(result); + } else { + if(safetyCategoryA == 'benzodiazepines') { + return callback({'err': true, 'code': 'ssb', 'msg': 'Drug A and B are the same safety category.'}); + } else { + return callback({'err': true, 'code': 'ssc', 'msg': 'Drug A and B are the same safety category.'}); + } + } + } else { + return callback(false); + } + } else { + return callback({'err': true, 'msg': 'Drug B not found.'}); + } + }.bind(this)); + } else { + return callback({'err': true, 'msg': 'Drug A not found.'}); + } + }.bind(this)); + }, + + 'getDrug': function(name, callback) { + name = name.toLowerCase(); + this.db.read('drugs', name, function(err, drug) { + if(!drug) { + this.db.scan('drugs', function(dMatch) { + if(_.include(dMatch.aliases, name)) { + drug = dMatch; + if(!_.isUndefined(drug.aliases)) drug.properties.aliases = drug.aliases; + } + }, function() { + if(drug) { + if(!_.isUndefined(drug.aliases)) drug.properties.aliases = drug.aliases; + if(!_.isUndefined(drug.categories)) drug.properties.categories = drug.categories; + + if(_.has(dbot.modules.tripsit.combos, drug.name)) { + drug.combos = dbot.modules.tripsit.combos[drug.name]; + } + +if(_.has(drug.properties, 'dose')) { + var doses = drug.properties.dose.split('|'); + var regex = /(([\w-]+):\s([\/\.\w\d-\+µ]+))/ig; + drug.formatted_dose = {}; + if(doses.length > 1 || !doses[0].split(' ')[0].match(':')) { + _.each(doses, function(dString) { + dString = dString.replace(/\s\s+/g, ' '); + var roa = dString.trim().split(' ')[0]; + var match = regex.exec(dString); + if(roa.match(/note/i)) { + drug.dose_note = dString; + } else { + drug.formatted_dose[roa] = {}; + while(match != null) { + drug.formatted_dose[roa][match[2]] = match[3]; + match = regex.exec(dString); + } + } + }); + } else { + var roa = 'Oral'; + var match = regex.exec(doses[0]); + if(roa.match(/note/i)) { + drug.dose_note = doses[0]; + } else { + drug.formatted_dose[roa] = {}; + while(match != null) { + drug.formatted_dose[roa][match[2]] = match[3]; + match = regex.exec(doses[0]); + } + } + } +} + if(_.has(drug.properties, 'effects')) { + drug.formatted_effects = _.collect(drug.properties.effects.split(/[\.,]+/), function(item) { + return item.trim(); + }); + } + + if(_.has(drug.properties, 'duration')) { + var roas = drug.properties.duration.split('|'); + drug.formatted_duration = {}; + if(roas.length > 1 || roas[0].match(':')) { + _.each(roas, function(roa) { + + if(roa.toLowerCase().match('note')) { + return; + } + var match = roa.match(/([\w-\/]+):?\s([\.\w\d-\+]+)/i); +if(match) { + drug.formatted_duration[match[1]] = match[2]; +} + }); + } else { + var match = drug.properties['duration'].match(/([\.\w\d-\+]+)/i); + drug.formatted_duration = {'value':match[1]}; + } + if(drug.properties.duration.indexOf('minutes') != -1) { + drug.formatted_duration._unit = 'minutes'; + } + if(drug.properties.duration.indexOf('hours') != -1) { + drug.formatted_duration._unit = 'hours'; + } + } + + if(_.has(drug.properties, 'onset')) { + var roas = drug.properties.onset.split('|'); + drug.formatted_onset = {}; + if(roas.length > 1 || roas[0].match(':')) { + _.each(roas, function(roa) { + if(roa.toLowerCase().match('note')) { + return; + } + var match = roa.match(/([\w-\/]+):?\s([\.\w\d-\+]+)/i); +if(match) { + drug.formatted_onset[match[1]] = match[2]; +} + }); + } else { + var match = drug.properties['onset'].match(/([\.\w\d-\+]+)/i); + drug.formatted_onset = {'value':match[1]}; + } + if(drug.properties.onset.indexOf('minutes') != -1) { + drug.formatted_onset._unit = 'minutes'; + } + if(drug.properties.onset.indexOf('hours') != -1) { + drug.formatted_onset._unit = 'hours'; + } + } + + if(_.has(drug.properties, 'after-effects')) { + var roas = drug.properties['after-effects'].split('|'); + drug.formatted_aftereffects = {}; + if(roas.length > 1 || roas[0].match(':')) { + _.each(roas, function(roa) { + + if(roa.toLowerCase().match('note')) { + return; + } + var match = roa.match(/([\w\/]+):?\s([\.\w\d-\+]+)/i); +if(match) { + drug.formatted_aftereffects[match[1]] = match[2]; +} + }); + } else { + var match = drug.properties['after-effects'].match(/([\.\w\d-\+]+)/i); + drug.formatted_aftereffects = {'value':match[1]}; + } + if(drug.properties['after-effects'].indexOf('minutes') != -1) { + drug.formatted_aftereffects._unit = 'minutes'; + } + if(drug.properties['after-effects'].indexOf('hours') != -1) { + drug.formatted_aftereffects._unit = 'hours'; + } + } +if(!_.has(drug, 'pretty_name')) { +drug.pretty_name = drug.name; +if(drug.name.length <= 4 || drug.name.indexOf('-') != -1) { + drug.pretty_name = drug.name.toUpperCase(); + } else { + drug.pretty_name = drug.name.charAt(0).toUpperCase() + drug.name.slice(1); + } +drug.pretty_name = drug.pretty_name.replace(/MEO/, 'MeO'); +drug.pretty_name = drug.pretty_name.replace(/ACO/, 'AcO'); +drug.pretty_name = drug.pretty_name.replace(/NBOME/, 'NBOMe'); +drug.pretty_name = drug.pretty_name.replace(/MIPT/, 'MiPT'); +drug.pretty_name = drug.pretty_name.replace(/DIPT/, 'DiPT'); +} + } + + if(drug) { + callback(drug); + } else { + callback({'err': true, 'msg': 'No drug found.'}); + } + }); + } else { + + if(drug) { + if(!_.isUndefined(drug.aliases)) drug.properties.aliases = drug.aliases; + if(!_.isUndefined(drug.categories)) drug.properties.categories = drug.categories; + + if(_.has(dbot.modules.tripsit.combos, drug.name)) { + drug.combos = dbot.modules.tripsit.combos[drug.name]; + } + if(_.has(drug.properties, 'dose')) { + var doses = drug.properties.dose.split('|'); + var regex = /(([\w-]+):\s([\/\.\w\d-\+µ]+))/ig; + drug.formatted_dose = {}; + if(doses.length > 1 || !doses[0].split(' ')[0].match(':')) { + _.each(doses, function(dString) { + dString = dString.replace(/\s\s+/g, ' '); + var roa = dString.trim().split(' ')[0]; + var match = regex.exec(dString); + if(roa.match(/note/i)) { + drug.dose_note = dString; + } else { + drug.formatted_dose[roa] = {}; + while(match != null) { + drug.formatted_dose[roa][match[2]] = match[3]; + match = regex.exec(dString); + } + } + }); + } else { + var roa = 'Oral'; + var match = regex.exec(doses[0]); + if(roa.match(/note/i)) { + drug.dose_note = doses[0]; + } else { + drug.formatted_dose[roa] = {}; + while(match != null) { + drug.formatted_dose[roa][match[2]] = match[3]; + match = regex.exec(doses[0]); + } + } + } + +} + + if(_.has(drug.properties, 'effects')) { + drug.formatted_effects = _.collect(drug.properties.effects.split(/[\.,]+/), function(item) { + return item.trim(); + }); + } + + if(_.has(drug.properties, 'duration')) { + var roas = drug.properties.duration.split('|'); + drug.formatted_duration = {}; + if(roas.length > 1 || roas[0].match(':')) { + _.each(roas, function(roa) { + + if(roa.toLowerCase().match('note')) { + return; + } + var match = roa.match(/([\w-\/]+):?\s([\.\w\d-\+]+)/i); +if(match) { + drug.formatted_duration[match[1]] = match[2]; +} + }); + } else { + var match = drug.properties['duration'].match(/([\.\w\d-\+]+)/i); + drug.formatted_duration = {'value':match[1]}; + } + if(drug.properties.duration.indexOf('minutes') != -1) { + drug.formatted_duration._unit = 'minutes'; + } + if(drug.properties.duration.indexOf('hours') != -1) { + drug.formatted_duration._unit = 'hours'; + } + } + + if(_.has(drug.properties, 'onset')) { + var roas = drug.properties.onset.split('|'); + drug.formatted_onset = {}; + if(roas.length > 1 || roas[0].match(':')) { + _.each(roas, function(roa) { + + if(roa.toLowerCase().match('note')) { + return; + } + var match = roa.match(/([\/\w-]+):??\s([\.\w\d-\+]+)/i); +if(match) { + drug.formatted_onset[match[1]] = match[2]; +} + }); + } else { + var match = drug.properties['onset'].match(/([\.\w\d-\+]+)/i); + drug.formatted_onset = {'value':match[1]}; + } + if(drug.properties.onset.indexOf('minutes') != -1) { + drug.formatted_onset._unit = 'minutes'; + } + if(drug.properties.onset.indexOf('hours') != -1) { + drug.formatted_onset._unit = 'hours'; + } + } + + if(_.has(drug.properties, 'after-effects')) { + var roas = drug.properties['after-effects'].split('|'); + drug.formatted_aftereffects = {}; + if(roas.length > 1 || roas[0].match(':')) { + _.each(roas, function(roa) { + + if(roa.toLowerCase().match('note')) { + return; + } + var match = roa.match(/([\w\/]+):?\s([\.\w\d-\+]+)/i); +if(match) { + drug.formatted_aftereffects[match[1]] = match[2]; +} + }); + } else { + var match = drug.properties['after-effects'].match(/([\.\w\d-\+]+)/i); + drug.formatted_aftereffects = {'value':match[1]}; + } + if(drug.properties['after-effects'].indexOf('minutes') != -1) { + drug.formatted_aftereffects._unit = 'minutes'; + } + if(drug.properties['after-effects'].indexOf('hours') != -1) { + drug.formatted_aftereffects._unit = 'hours'; + } + } + +if(!_.has(drug, 'pretty_name')) { +drug.pretty_name = drug.name; + if(drug.name.length <= 4 || drug.name.indexOf('-') != -1) { + drug.pretty_name = drug.name.toUpperCase(); + } else { + drug.pretty_name = drug.name.charAt(0).toUpperCase() + drug.name.slice(1); + } +drug.pretty_name = drug.pretty_name.replace(/MEO/, 'MeO'); +drug.pretty_name = drug.pretty_name.replace(/ACO/, 'AcO'); +drug.pretty_name = drug.pretty_name.replace(/NBOME/, 'NBOMe'); +drug.pretty_name = drug.pretty_name.replace(/MIPT/, 'MiPT'); +drug.pretty_name = drug.pretty_name.replace(/DIPT/, 'DiPT'); +} + + + } + if(drug) { + callback(drug); + } else { + callback({'err': true, 'msg': 'No drug found.'}); + } + + } + }.bind(this)); + }, + + 'getAllDrugNames': function(callback) { + var names = []; + this.db.scan('drugs', function(drug) { + if(drug) { + names.push(drug.name); + } + }, function() { + callback(names); + }); + }, + + 'getAllDrugNamesByCategory': function(category, callback) { + this.api.getAllDrugs(function(names) { + callback(_.pluck(_.filter(names, function(a) { return _.include(a.categories, category); }), 'name')); + }); + }, + + 'getAllDrugs': function(callback) { + this.api.getAllDrugNames(function(names) { + var drugs = {}; + async.each(names, function(name, done) { + if(!_.isUndefined(name)) { + this.api.getDrug(name, function(drug) { + drugs[name] = drug; + done(); + }); + } else { + done(); + } + }.bind(this), function() { + callback(drugs); + }); + }.bind(this)); + }, + 'getAllCategories': function(callback) { + var categories = {}; + this.db.scan('drug_categories', function(cat) { + categories[cat.name] = cat; + }, function() { + callback(categories); + }); + }, + +'getAllDrugAliases': function(callback) { + this.api.getAllDrugNames(function(names) { + var fullNames = []; + async.each(names, function(name, done) { + if(!_.isUndefined(name)) { + this.api.getDrug(name, function(drug) { +fullNames.push(name); +fullNames = _.union(fullNames, drug.aliases); + done(); + }); + } else { + done(); + } + }.bind(this), function() { + callback(fullNames); + }); + }.bind(this)); + }, + + 'delDrug': function(name, callback) { + this.db.del('drugs', name.toLowerCase(), function() { + callback(); + }); + }, + + 'setDrugProperty': function(drug, property, content, callback) { + drug.properties[property] = content; + this.db.save('drugs', drug.name, drug, callback); + }, + + 'setCategoryProperty': function(category, property, content, callback) { + category[property] = content; + this.db.save('drug_categories', category.name, category, callback); + }, + + 'delDrugProperty': function(drug, property, callback) { + delete drug.properties[property]; + this.db.save('drugs', drug.name, drug, callback); + }, + + 'createDrug': function(name, callback) { + name = name.toLowerCase(); + this.db.create('drugs', name, { + 'name': name, + 'properties': {} + }, callback); + } + }; + + api['getDrug'].external = true; + api['getDrug'].extMap = [ 'name', 'callback' ]; + api['getAllDrugNames'].external = true; + api['getAllDrugNames'].extMap = [ 'callback' ]; + api['getAllDrugNamesByCategory'].external = true; + api['getAllDrugNamesByCategory'].extMap = [ 'category', 'callback' ]; + api['getAllDrugAliases'].external = true; + api['getAllDrugAliases'].extMap = [ 'callback' ]; + api['getAllDrugs'].external = true; + api['getAllDrugs'].extMap = [ 'callback' ]; + api['getAllCategories'].external = true; + api['getAllCategories'].extMap = [ 'callback' ]; + api['getInteraction'].external = true; + api['getInteraction'].extMap = [ 'drugA', 'drugB', 'callback' ]; + + return api; +}; + +exports.fetch = function(dbot) { + return api(dbot); +}; diff --git a/tripsit/combo.json b/tripsit/combo.json new file mode 100644 index 0000000..a111272 --- /dev/null +++ b/tripsit/combo.json @@ -0,0 +1,755 @@ +{ + "lsd": { + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Safe & Synergy", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Safe & Synergy", + "αmt": "Safe & Synergy", + "5-meo-xxt": "Safe & Synergy", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & Synergy", + "pcp": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Safe & No Synergy", + "mdma": "Safe & Synergy", + "cocaine": "Safe & No Synergy", + "caffeine": "Safe & No Synergy", + "alcohol": "Safe & No Synergy", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Safe & No Synergy", + "tramadol": "Safe & Decrease", + "benzodiazepines": "Safe & Decrease", + "maois": "Safe & Decrease", + "ssris": "Safe & Decrease" + }, + "mushrooms": { + "lsd": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Safe & Synergy", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Safe & Synergy", + "αmt": "Safe & Synergy", + "5-meo-xxt": "Safe & Synergy", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & Synergy", + "pcp": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Safe & No Synergy", + "mdma": "Safe & Synergy", + "cocaine": "Safe & No Synergy", + "caffeine": "Safe & No Synergy", + "alcohol": "Safe & No Synergy", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Safe & No Synergy", + "tramadol": "Safe & Decrease", + "benzodiazepines": "Safe & Decrease", + "maois": "Safe & Synergy", + "ssris": "Safe & Decrease" + }, + "dmt": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Safe & Synergy", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Safe & Synergy", + "αmt": "Safe & Synergy", + "5-meo-xxt": "Safe & Synergy", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & Synergy", + "pcp": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Safe & No Synergy", + "mdma": "Safe & Synergy", + "cocaine": "Safe & No Synergy", + "caffeine": "Safe & No Synergy", + "alcohol": "Safe & Decrease", + "ghb/gbl": "Safe & Decrease", + "opioids": "Safe & No Synergy", + "tramadol": "Safe & Decrease", + "benzodiazepines": "Safe & Decrease", + "maois": "Safe & Synergy", + "ssris": "Safe & Decrease" + }, + "mescaline": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "dox": "Safe & Synergy", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Unsafe", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & Synergy", + "pcp": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Safe & No Synergy", + "mdma": "Safe & Synergy", + "cocaine": "Safe & No Synergy", + "caffeine": "Safe & No Synergy", + "alcohol": "Safe & No Synergy", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Safe & No Synergy", + "tramadol": "Deadly", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Safe & Decrease" + }, + "dox": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Unsafe", + "cannabis": "Safe & Synergy", + "ketamine": "Unsafe", + "mxe": "Unsafe", + "dxm": "Unsafe", + "pcp": "Unsafe", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Unsafe", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Unsafe", + "ghb/gbl": "Unsafe", + "opioids": "Unsafe", + "tramadol": "Deadly", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Safe & Decrease" + }, + "nbomes": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Unsafe", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & Synergy", + "pcp": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Safe & Synergy", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Safe & No Synergy", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Safe & No Synergy", + "tramadol": "Deadly", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Safe & Decrease" + }, + "2c-x": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Safe & Synergy", + "nbomes": "Safe & Synergy", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Unsafe", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & Synergy", + "pcp": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Safe & Synergy", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Safe & No Synergy", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Safe & No Synergy", + "tramadol": "Deadly", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Safe & Decrease" + }, + "2c-t-x": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Serotonin Syndrome", + "dox": "Serotonin Syndrome", + "nbomes": "Serotonin Syndrome", + "2c-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Serotonin Syndrome", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Serotonin Syndrome", + "dxm": "Serotonin Syndrome", + "pcp": "Serotonin Syndrome", + "nitrous": "Safe & Synergy", + "amphetamines": "Serotonin Syndrome", + "mdma": "Serotonin Syndrome", + "cocaine": "Serotonin Syndrome", + "caffeine": "Unsafe", + "alcohol": "Unsafe", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Unsafe", + "tramadol": "Serotonin Syndrome", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Serotonin Syndrome" + }, + "αmt": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Serotonin Syndrome", + "dox": "Serotonin Syndrome", + "nbomes": "Serotonin Syndrome", + "2c-x": "Serotonin Syndrome", + "2c-t-x": "Serotonin Syndrome", + "5-meo-xxt": "Serotonin Syndrome", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Serotonin Syndrome", + "dxm": "Serotonin Syndrome", + "pcp": "Serotonin Syndrome", + "nitrous": "Safe & Synergy", + "amphetamines": "Serotonin Syndrome", + "mdma": "Serotonin Syndrome", + "cocaine": "Serotonin Syndrome", + "caffeine": "Unsafe", + "alcohol": "Unsafe", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Unsafe", + "tramadol": "Serotonin Syndrome", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Serotonin Syndrome" + }, + "5-meo-xxt": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Unsafe", + "dox": "Unsafe", + "nbomes": "Unsafe", + "2c-x": "Unsafe", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Unsafe", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Safe & No Synergy", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Safe & No Synergy", + "tramadol": "Serotonin Syndrome", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Serotonin Syndrome" + }, + "cannabis": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Safe & Synergy", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Safe & Synergy", + "αmt": "Safe & Synergy", + "5-meo-xxt": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & Synergy", + "pcp": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Safe & No Synergy", + "mdma": "Safe & Synergy", + "cocaine": "Safe & No Synergy", + "caffeine": "Safe & No Synergy", + "alcohol": "Safe & No Synergy", + "ghb/gbl": "Safe & Synergy", + "opioids": "Safe & Synergy", + "tramadol": "Safe & Synergy", + "benzodiazepines": "Safe & Decrease", + "maois": "Safe & Synergy", + "ssris": "Safe & No Synergy" + }, + "ketamine": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Unsafe", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Safe & Synergy", + "αmt": "Safe & Synergy", + "5-meo-xxt": "Safe & Synergy", + "cannabis": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & No Synergy", + "pcp": "Safe & Synergy", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Safe & Synergy", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Deadly", + "ghb/gbl": "Deadly", + "opioids": "Deadly", + "tramadol": "Deadly", + "benzodiazepines": "Unsafe", + "maois": "Safe & No Synergy", + "ssris": "Safe & No Synergy" + }, + "mxe": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Unsafe", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Serotonin Syndrome", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "dxm": "Serotonin Syndrome", + "pcp": "Serotonin Syndrome", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Unsafe", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Deadly", + "ghb/gbl": "Deadly", + "opioids": "Deadly", + "tramadol": "Serotonin Syndrome", + "benzodiazepines": "Unsafe", + "maois": "Serotonin Syndrome", + "ssris": "Unsafe" + }, + "dxm": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Unsafe", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Serotonin Syndrome", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & No Synergy", + "mxe": "Serotonin Syndrome", + "pcp": "Serotonin Syndrome", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Serotonin Syndrome", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Deadly", + "ghb/gbl": "Deadly", + "opioids": "Deadly", + "tramadol": "Serotonin Syndrome", + "benzodiazepines": "Unsafe", + "maois": "Serotonin Syndrome", + "ssris": "Serotonin Syndrome" + }, + "pcp": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Unsafe", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Serotonin Syndrome", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Serotonin Syndrome", + "dxm": "Serotonin Syndrome", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Unsafe", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Deadly", + "ghb/gbl": "Deadly", + "opioids": "Deadly", + "tramadol": "Serotonin Syndrome", + "benzodiazepines": "Unsafe", + "maois": "Serotonin Syndrome", + "ssris": "Unsafe" + }, + "nitrous": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Safe & Synergy", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Safe & Synergy", + "αmt": "Safe & Synergy", + "5-meo-xxt": "Safe & Synergy", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Safe & Synergy", + "dxm": "Safe & Synergy", + "pcp": "Safe & Synergy", + "amphetamines": "Safe & Synergy", + "mdma": "Safe & Synergy", + "cocaine": "Safe & Synergy", + "caffeine": "Safe & No Synergy", + "alcohol": "Unsafe", + "ghb/gbl": "Unsafe", + "opioids": "Safe & Decrease", + "tramadol": "Safe & Decrease", + "benzodiazepines": "Safe & Decrease", + "maois": "Safe & No Synergy", + "ssris": "Safe & No Synergy" + }, + "amphetamines": { + "lsd": "Safe & No Synergy", + "mushrooms": "Safe & No Synergy", + "dmt": "Safe & No Synergy", + "mescaline": "Safe & No Synergy", + "dox": "Unsafe", + "nbomes": "Unsafe", + "2c-x": "Unsafe", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Unsafe", + "cannabis": "Safe & No Synergy", + "ketamine": "Unsafe", + "mxe": "Unsafe", + "dxm": "Unsafe", + "pcp": "Unsafe", + "nitrous": "Safe & Synergy", + "mdma": "Unsafe", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Unsafe", + "ghb/gbl": "Unsafe", + "opioids": "Unsafe", + "tramadol": "Deadly", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Safe & No Synergy" + }, + "mdma": { + "lsd": "Safe & Synergy", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Safe & Synergy", + "dox": "Unsafe", + "nbomes": "Safe & Synergy", + "2c-x": "Safe & Synergy", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Unsafe", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & Synergy", + "mxe": "Unsafe", + "dxm": "Serotonin Syndrome", + "pcp": "Unsafe", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "cocaine": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Unsafe", + "ghb/gbl": "Safe & Synergy", + "opioids": "Unsafe", + "tramadol": "Deadly", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Safe & Decrease" + }, + "cocaine": { + "lsd": "Safe & No Synergy", + "mushrooms": "Safe & No Synergy", + "dmt": "Safe & No Synergy", + "mescaline": "Safe & No Synergy", + "dox": "Unsafe", + "nbomes": "Unsafe", + "2c-x": "Unsafe", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Unsafe", + "cannabis": "Safe & No Synergy", + "ketamine": "Unsafe", + "mxe": "Unsafe", + "dxm": "Unsafe", + "pcp": "Unsafe", + "nitrous": "Safe & Synergy", + "amphetamines": "Unsafe", + "mdma": "Unsafe", + "caffeine": "Unsafe", + "alcohol": "Unsafe", + "ghb/gbl": "Unsafe", + "opioids": "Deadly", + "tramadol": "Deadly", + "benzodiazepines": "Safe & Decrease", + "maois": "Serotonin Syndrome", + "ssris": "Unsafe" + }, + "caffeine": { + "lsd": "Safe & No Synergy", + "mushrooms": "Safe & No Synergy", + "dmt": "Safe & No Synergy", + "mescaline": "Safe & No Synergy", + "dox": "Unsafe", + "nbomes": "Unsafe", + "2c-x": "Unsafe", + "2c-t-x": "Unsafe", + "αmt": "Unsafe", + "5-meo-xxt": "Unsafe", + "cannabis": "Safe & No Synergy", + "ketamine": "Unsafe", + "mxe": "Unsafe", + "dxm": "Unsafe", + "pcp": "Unsafe", + "nitrous": "Safe & No Synergy", + "amphetamines": "Unsafe", + "mdma": "Unsafe", + "cocaine": "Unsafe", + "alcohol": "Safe & No Synergy", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Safe & No Synergy", + "tramadol": "Safe & Synergy", + "benzodiazepines": "Safe & Decrease", + "maois": "Safe & No Synergy", + "ssris": "Safe & No Synergy" + }, + "alcohol": { + "lsd": "Safe & No Synergy", + "mushrooms": "Safe & No Synergy", + "dmt": "Safe & Decrease", + "mescaline": "Safe & No Synergy", + "dox": "Unsafe", + "nbomes": "Safe & No Synergy", + "2c-x": "Safe & No Synergy", + "2c-t-x": "Unsafe", + "αmt": "Unsafe", + "5-meo-xxt": "Safe & No Synergy", + "cannabis": "Safe & No Synergy", + "ketamine": "Deadly", + "mxe": "Deadly", + "dxm": "Deadly", + "pcp": "Deadly", + "nitrous": "Unsafe", + "amphetamines": "Unsafe", + "mdma": "Unsafe", + "cocaine": "Unsafe", + "caffeine": "Safe & No Synergy", + "ghb/gbl": "Deadly", + "opioids": "Deadly", + "tramadol": "Deadly", + "benzodiazepines": "Deadly", + "maois": "Unsafe", + "ssris": "Unsafe" + }, + "ghb/gbl": { + "lsd": "Safe & No Synergy", + "mushrooms": "Safe & No Synergy", + "dmt": "Safe & Decrease", + "mescaline": "Safe & No Synergy", + "dox": "Unsafe", + "nbomes": "Safe & No Synergy", + "2c-x": "Safe & No Synergy", + "2c-t-x": "Safe & No Synergy", + "αmt": "Safe & No Synergy", + "5-meo-xxt": "Safe & No Synergy", + "cannabis": "Safe & Synergy", + "ketamine": "Deadly", + "mxe": "Deadly", + "dxm": "Deadly", + "pcp": "Deadly", + "nitrous": "Unsafe", + "amphetamines": "Unsafe", + "mdma": "Safe & Synergy", + "cocaine": "Unsafe", + "caffeine": "Safe & No Synergy", + "alcohol": "Deadly", + "opioids": "Deadly", + "tramadol": "Deadly", + "benzodiazepines": "Deadly", + "maois": "Safe & Synergy", + "ssris": "Safe & No Synergy" + }, + "opioids": { + "lsd": "Safe & No Synergy", + "mushrooms": "Safe & No Synergy", + "dmt": "Safe & No Synergy", + "mescaline": "Safe & No Synergy", + "dox": "Unsafe", + "nbomes": "Safe & No Synergy", + "2c-x": "Safe & No Synergy", + "2c-t-x": "Unsafe", + "αmt": "Unsafe", + "5-meo-xxt": "Safe & No Synergy", + "cannabis": "Safe & Synergy", + "ketamine": "Deadly", + "mxe": "Deadly", + "dxm": "Deadly", + "pcp": "Deadly", + "nitrous": "Safe & Decrease", + "amphetamines": "Unsafe", + "mdma": "Unsafe", + "cocaine": "Deadly", + "caffeine": "Safe & No Synergy", + "alcohol": "Deadly", + "ghb/gbl": "Deadly", + "tramadol": "Deadly", + "benzodiazepines": "Deadly", + "maois": "Unsafe", + "ssris": "Serotonin Syndrome" + }, + "tramadol": { + "lsd": "Safe & Decrease", + "mushrooms": "Safe & Decrease", + "dmt": "Safe & Decrease", + "mescaline": "Deadly", + "dox": "Deadly", + "nbomes": "Deadly", + "2c-x": "Deadly", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Serotonin Syndrome", + "cannabis": "Safe & Synergy", + "ketamine": "Deadly", + "mxe": "Serotonin Syndrome", + "dxm": "Serotonin Syndrome", + "pcp": "Serotonin Syndrome", + "nitrous": "Safe & Decrease", + "amphetamines": "Deadly", + "mdma": "Deadly", + "cocaine": "Deadly", + "caffeine": "Safe & Synergy", + "alcohol": "Deadly", + "ghb/gbl": "Deadly", + "opioids": "Deadly", + "benzodiazepines": "Deadly", + "maois": "Serotonin Syndrome", + "ssris": "Serotonin Syndrome" + }, + "benzodiazepines": { + "lsd": "Safe & Decrease", + "mushrooms": "Safe & Decrease", + "dmt": "Safe & Decrease", + "mescaline": "Safe & Decrease", + "dox": "Safe & Decrease", + "nbomes": "Safe & Decrease", + "2c-x": "Safe & Decrease", + "2c-t-x": "Safe & Decrease", + "αmt": "Safe & Decrease", + "5-meo-xxt": "Safe & Decrease", + "cannabis": "Safe & Decrease", + "ketamine": "Unsafe", + "mxe": "Unsafe", + "dxm": "Unsafe", + "pcp": "Unsafe", + "nitrous": "Safe & Decrease", + "amphetamines": "Safe & Decrease", + "mdma": "Safe & Decrease", + "cocaine": "Safe & Decrease", + "caffeine": "Safe & Decrease", + "alcohol": "Deadly", + "ghb/gbl": "Deadly", + "opioids": "Deadly", + "tramadol": "Deadly", + "maois": "Safe & Synergy", + "ssris": "Safe & No Synergy" + }, + "maois": { + "lsd": "Safe & Decrease", + "mushrooms": "Safe & Synergy", + "dmt": "Safe & Synergy", + "mescaline": "Serotonin Syndrome", + "dox": "Serotonin Syndrome", + "nbomes": "Serotonin Syndrome", + "2c-x": "Serotonin Syndrome", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Serotonin Syndrome", + "cannabis": "Safe & Synergy", + "ketamine": "Safe & No Synergy", + "mxe": "Serotonin Syndrome", + "dxm": "Serotonin Syndrome", + "pcp": "Serotonin Syndrome", + "nitrous": "Safe & No Synergy", + "amphetamines": "Serotonin Syndrome", + "mdma": "Serotonin Syndrome", + "cocaine": "Serotonin Syndrome", + "caffeine": "Safe & No Synergy", + "alcohol": "Unsafe", + "ghb/gbl": "Safe & Synergy", + "opioids": "Unsafe", + "tramadol": "Serotonin Syndrome", + "benzodiazepines": "Safe & Synergy", + "ssris": "Serotonin Syndrome" + }, + "ssris": { + "lsd": "Safe & Decrease", + "mushrooms": "Safe & Decrease", + "dmt": "Safe & Decrease", + "mescaline": "Safe & Decrease", + "dox": "Safe & Decrease", + "nbomes": "Safe & Decrease", + "2c-x": "Safe & Decrease", + "2c-t-x": "Serotonin Syndrome", + "αmt": "Serotonin Syndrome", + "5-meo-xxt": "Serotonin Syndrome", + "cannabis": "Safe & No Synergy", + "ketamine": "Safe & No Synergy", + "mxe": "Unsafe", + "dxm": "Serotonin Syndrome", + "pcp": "Unsafe", + "nitrous": "Safe & No Synergy", + "amphetamines": "Safe & No Synergy", + "mdma": "Safe & Decrease", + "cocaine": "Unsafe", + "caffeine": "Safe & No Synergy", + "alcohol": "Unsafe", + "ghb/gbl": "Safe & No Synergy", + "opioids": "Serotonin Syndrome", + "tramadol": "Serotonin Syndrome", + "benzodiazepines": "Safe & No Synergy", + "maois": "Serotonin Syndrome" + } +} diff --git a/tripsit/config.json b/tripsit/config.json new file mode 100644 index 0000000..c4fb1ae --- /dev/null +++ b/tripsit/config.json @@ -0,0 +1,6 @@ +{ + "dependencies": [ "report" ], + "tripsitters": [], + "dbType": "redis", + "wikiTemplate": "= General Information = \n{summary}\nCategories: {categories} \n\n== History ==\n\n= Dosage = \n {dose} \n\n= Duration =\nOnset: {onset}\nDuration: {duration}\nAfter-effects: {after-effects} \n\n= Effects = \n {effects} \n\n=Harm Reduction= \n Avoid: {avoid} \n\n= Chemistry and Pharmacology = \n\n= Storage = \n\n= Legal =" +} diff --git a/tripsit/pages.js b/tripsit/pages.js new file mode 100644 index 0000000..1113ca6 --- /dev/null +++ b/tripsit/pages.js @@ -0,0 +1,184 @@ +var _ = require('underscore'); + +var cap = function(str) { + return str.charAt(0).toUpperCase() + str.slice(1); +} + +var pages = function(dbot) { + var pages = { + '/factsheet/test': function(req, res) { + res.end(req.user.access); + }, + + '/factsheet/wikitemplate/:drug': function(req, res) { + this.api.getDrug(req.params.drug, function(drug) { + if(drug) { + d = drug.properties; +if(!_.has(d,'categories')) d.categories = []; +res.header("Content-Type", "text/plain; charset=utf-8"); + var template = this.config.wikiTemplate.format({ + 'dose': d.dose, + 'onset': d.onset, + 'duration': d.duration, + 'avoid': d.avoid, + 'categories': d.categories.join(', '), + 'summary': d.summary, + 'after-effects': d['after-effects'], + 'effects': d.effects + }); + template += '\n\n[[Category:Drugs]]\n'; + _.each(d.categories,function(cat){template+='[[Category:'+cap(cat)+']]\n';}); + res.end(template); + } + }.bind(this)); + }, + + '/factsheet': function(req, res) { + var drugs = []; + this.db.scan('drugs', function(drug) { + if(drug && _.has(drug, 'name') && _.has(drug, 'properties')) { + if(drug.name.length <= 4 || drug.name.indexOf('-') != -1) { + drug.name = drug.name.toUpperCase(); + } else { + drug.name = drug.name.charAt(0).toUpperCase() + drug.name.slice(1); + } +drug.name = drug.name.replace(/MEO/, 'MeO'); +drug.name = drug.name.replace(/ACO/, 'AcO'); +drug.name = drug.name.replace(/NBOME/, 'NBOMe'); +drug.name = drug.name.replace(/MIPT/, 'MiPT'); +drug.name = drug.name.replace(/DIPT/, 'DiPT'); + drugs.push(drug); + } + }, function() { +drugs = _.sortBy(drugs, 'name'); + res.render('fs_list', { + 'drugs': drugs, + 'thing': 'Factsheets' + }); + }); + }, + + '/factsheet/edit': function(req, res) { + var name = req.body.name, + params = req.body, + pValues = _.omit(params, 'name', 'newname', 'categories', 'aliases', 'formatted_dose'), + response = { + 'error': null, + 'drug': null + }; + + if(!_.has(req, 'user') || (_.has(req, 'user') && req.user.access == 'user')) { + response.error = 'Unauthenticated.'; + return res.json(response); + } + + this.api.getDrug(params.name, function(drug) { + if(drug) { + if(_.has(params, 'categories')) { + var categories = params.categories.replace(/\s/g,'').split(','); + availableCategories = [ 'psychedelic', 'benzodiazepine', + 'dissociative', 'opioid', 'depressant', 'common', 'stimulant', 'habit-forming', 'research-chemical', 'empathogen', 'deliriant', 'nootropic', 'tentative', 'inactive' ]; + if(_.difference(categories, availableCategories).length !== 0) { + response.error = 'Invalid category.'; + return res.json(response); + } + } + + drug.categories = categories; + + _.each(pValues, function(property, index) { + drug.properties[index] = property; + }); + + this.db.save('drugs', drug.name, drug, function(err, drug) { + if(_.has(params, 'newname') && params.newname !== drug.name) { + this.api.getDrug(params.newname, function(oDrug) { + if(oDrug) { + response.error = params.newname + ' already exists.'; + return res.json(response); + } else { + this.api.delDrug(drug.name, function() { + drug.name = params.newname; + this.db.create('drugs', drug.name, drug, function() { + this.api.getDrug(drug.name, function(drug) { + response.drug = drug; + res.json(response); + dbot.say('tripsit', '#content', dbot.t('websetdrug_log', { + 'user': req.user.primaryNick, + 'drug': drug.name + })); + }); + }.bind(this)); + }.bind(this)); + } + }.bind(this)); + } else { + this.api.getDrug(drug.name, function(drug) { + response.drug = drug; + res.json(response); + dbot.say('tripsit', '#content', dbot.t('websetdrug_log', { + 'user': req.user.primaryNick, + 'drug': drug.name + })); + + }); + } + }.bind(this)); + } else { + response.error = 'Unknown drug.'; + res.json(response); + } + }.bind(this)); + }, + + '/factsheet/:drug': function(req, res) { + this.api.getDrug(req.params.drug, function(drug) { + if(drug && !_.has(drug, 'err')) { +if(drug.name.length <= 3 || drug.name.indexOf('-') != -1) { + drug.name = drug.name.toUpperCase(); + } else { + drug.name = drug.name.charAt(0).toUpperCase() + drug.name.slice(1); + } + if(_.has(drug.properties, 'dose')) { // LAAAAME + drug.properties.dose = drug.properties.dose.split('|'); + } + + if(_.has(drug.properties, 'onset')) { // LAAAAME + drug.properties.onset = drug.properties.onset.split('|'); + } + + if(_.has(drug.properties, 'wiki')) { // This is also kinda lame + drug.wiki = drug.properties.wiki; + delete drug.properties.wiki; + } + + var order = _.union(['summary', 'dose', 'onset', 'duration'], _.keys(drug.properties)); + + res.render('factsheet', { + 'drug': drug, + 'order': order, + 'thing': drug.name + ' Factsheet' + }); + } else { + res.render('error', { + 'name': req.params.drug + }); + } + }); + }, + + '/chanlist': function(req, res) { + res.render('oclist', { + 'channels': this.channels + }); + } + }; + + pages['/factsheet/edit'].type = 'post'; + + return pages; +} + +exports.fetch = function(dbot) { + return pages(dbot); +}; diff --git a/tripsit/strings.json b/tripsit/strings.json new file mode 100644 index 0000000..685f273 --- /dev/null +++ b/tripsit/strings.json @@ -0,0 +1,53 @@ +{ + "tripsit_help": { + "en": "Attention: {user} needs some help in {channel}", + "fr": "Attention : {user} a besoin d'aide dans {channel}.", + "de": "Achtung: {user} benötigt Hilfe in {channel}." + }, + "tripsit_help_confirm": { + "en": "{user}: Thanks, we've notified our tripsitters and they'll be with you shortly. In the mean time you can help us help you by sharing your substance, dose, time of dose, mindset and any other relevant info. Remember, you're in good hands here.", + "fr": "{user} : Merci, nous avons notifié nos tripsitters et ils seront bientôt avec vous. En attendant, vous pouvez nous aider en indiquant la substance consommée, la dose, l'heure de prise, votre état d'esprit et tout autre information importante. Rappelez-vous, vous êtes entre de bonnes mains ici.", + "de": "{user}: Danke, wir haben unsere tripsitter informiert und sie werden sich in Kürze bei dir melden. In der Zwischenzeit kannst du uns helfen, indem du uns Substanz, Dosis, Mindset und andere relevanten Informationen mitteilst. Denk dran, du bist in guten Händen hier." + }, + "tripsit_notifies_on": { + "en": "You will now receive notifications of new users in #tripsit.", + "de": "Du wirst keine Benachrichtigungen von neuen Benutzern in #tripsit erhalten." + }, + "tripsit_already_notified": { + "en": "You were already receiving notifications of new users in #tripsit.", + "de": "Du erhälst bereits Benachrichtigungen von neuen Benutzern in #tripsit." + }, + "tripsit_notifies_off": { + "en": "You will no longer receive notifications of new users in #tripsit.", + "de": "Du wirst nicht länger Benachrichtigungen von neuen Benutzern in #tripsit erhalten." + }, + "tripsit_notifies_already_off": { + "en": "You weren't receiving notifications of new users in #tripsit in the first place.", + "de": "Benachrichtigung von neuen Benutzern in #tripsit war bereits deaktiviert." + }, + "new_tripsit_user": { + "en": "[{type}] {user} has joined #tripsit and may need some help.", + "de": "[{type}] {user} hat #tripsit betreten und benötigt möglicherweise etwas Hilfe." + }, + "setdrug_log": { + "en": "[\u00036factsheets\u000f] {user} set {property} of {drug} to \"{content}\"" + }, + "addsource_log": { + "en": "[\u00036factsheets\u000f] {user} added source for {property} of {drug}: \"{content}\"" + }, + "rmsource_log": { + "en": "[\u00036factsheets\u000f] {user} removed source for {property} of {drug}: \"{content}\"" + }, + "websetdrug_log": { + "en": "[\u00036factsheets\u000f] {user} modified {drug} (web)" + }, + "rmdrugproperty_log": { + "en": "[\u00036factsheets\u000f] {user} removed {property} from {drug}" + }, + "rmdrug_log": { + "en": "[\u00036factsheets\u000f] {user} removed {property}" + }, + "deleted_dupe": { + "en": "{creator}: Deleted duplicate #tripsit notification for {alias}, use #update" + } +} diff --git a/tripsit/tripsit b/tripsit/tripsit new file mode 160000 index 0000000..3f952b0 --- /dev/null +++ b/tripsit/tripsit @@ -0,0 +1 @@ +Subproject commit 3f952b039098db61c7fbeaf3a2b4140f12b0738a diff --git a/tripsit/tripsit.js b/tripsit/tripsit.js new file mode 100644 index 0000000..21eb118 --- /dev/null +++ b/tripsit/tripsit.js @@ -0,0 +1,1175 @@ +/** + * Module Name: TripSit + * Description: Functionality specific to the TripSit project over at + * http://tripsit.me/ + */ +var async = require('async'), + _ = require('underscore')._, + moment = require('moment'), + fs = require('fs'), + request = require('request'); + +function escapeRegExp(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); +} + +var tripsit = function(dbot) { + if(!_.has(dbot.db, 'tNotifies')) dbot.db.tNotifies = []; + this.tNotifies = dbot.db.tNotifies; + this.tcNotifies = dbot.db.tcNotifies; + this.ndb = dbot.modules.report.db; + this.tsChecks = {}; + this.channels = []; + this.recentNotifies = []; + this.combos = JSON.parse(fs.readFileSync('combo_beta.json', 'utf-8')); + this.opiates = JSON.parse(fs.readFileSync('oconvert.json', 'utf-8')); + this.bTable = { // TODO: Put in config + 'xanax': 0.5, + 'alprazolam': 0.5, + 'bromazepam': 5.5, + 'clonazepam': 0.5, + 'klonopin': 0.5, + 'lexotan': 5.5, + 'lexamil': 5.5, + 'chlordazepoxide': 25, + 'librium': 25, + 'etizolam': 1, + 'clobazam': 20, + 'valium': 10, + "clorazepate": 15, + "diazepam": 10, + "estazolam": 1.5, + "proSom": 1.5, + "nuctalon": 1.5, + "flunitrazepam": 1, + "rohypnol": 1, + "flurazepam": 23, + "dalmane": 23, + "halazepam": 20, + "paxipam": 20, + "ketazolam": 23, + "paxipam": 23, + "loprazolam": 1.5, + "dormonoct": 1.5, + "lorazepam": 1, + "ativan": 1, + "lormetazepam": 1.5, + "noctamid": 1.5, + "medazepam": 10, + "nobrium": 10, + "nitrazepam": 10, + "mogadon": 10, + "nordazepam": 10, + "oxazepam": 20, + "serax": 20, + "prazepam": 15, + "centrax": 15, + "quazepam": 20, + "Doral": 20, + "temazepam": 20, + "Restoril": 20, + "triazolam": 0.5, + "halcion": 0.5 + }; + + var commands = { + '~wat': function(event){var e=event.params.splice(1,event.params.length-1);var s=(e.length/_.random(2,4));for(var i=0;i start && notify.time < end) { + if(!_.has(feedback, notify.user)) { + feedback[notify.user] = { + 'id': notify.user, + 'count': 0 + }; + } + feedback[notify.user].count++; + + if(notify.message) { + _.each(notify.message.match(/ @([\d\w*|-]+)/g), function(tag) { + tag = tag.substr(2); + if(!_.has(tagBacks, tag)) { + tagBacks[tag] = 0; + } + tagBacks[tag]++; + }); + } + } + }, function() { + async.each(_.keys(feedback), function(f, next) { + f = feedback[f]; + dbot.api.users.getUser(f.id, function(err, user) { + if(user) { + f.nick = user.primaryNick; + } else { + f.nick = f.id; + } + next(); + }); + }, function() { + async.each(_.keys(tagBacks), function(t, next) { + console.log("'"+t+"'"); + dbot.api.users.resolveUser(event.server, t, function(err, user) { + if(user) { + console.log(user.id + ': ' + t); + if(!_.has(feedback, user.id)) feedback[user.id] = { + 'id': user.id, + 'nick': user.primaryNick, + 'count': 0 + } + feedback[user.id].count += tagBacks[t]; + } + next(); + }, true); + }, function() { + var total = 0; + async.eachSeries(_.keys(feedback), function(f, next) { + var f = feedback[f]; + dbot.api.nickserv.getUserHost(event.server, f.nick, function(h) { + if(h) { + var pos = h.match(/tripsit\/(.+)\/.+/); + } else { + pos == null; + } + if(pos && pos[1] != 'user') { + pos = pos[1]; + } else { + pos = 'nonstaff'; + } + + + event.reply(f.nick + ' - ' + pos + ': ' + f.count); + //event.reply(f.nick + ': ' + f.count); + total += f.count; + setTimeout(function() { + next(); + }, 200); + }); + }, function() { + event.reply('Total: ' + total); + }); + }); + }); + }); + }, + + '~gettripsitcalls': function(event) { + if(!_.include(this.tcNotifies, event.rUser.id)) { + this.tcNotifies.push(event.rUser.id); + event.reply("You will now be notified of ~tripsit calls"); + } else { + event.reply("You were already subscribed to ~tripsit calls!"); + } + }, + + '~notripsitcalls': function(event) { + if(_.include(this.tcNotifies, event.rUser.id)) { + dbot.db.tcNotifies = _.without(this.tcNotifies, event.rUser.id); + this.tcNotifies = dbot.db.tcNotifies; + event.reply("You are no longer subscribed to ~tripsit calls"); + } else { + event.reply("You weren't subscribed to ~tripsit calls in the first place mate"); + } + }, + + '~gettripsitentries': function(event) { + if(!_.include(this.tNotifies, event.rUser.id)) { + this.tNotifies.push(event.rUser.id); + event.reply(dbot.t('tripsit_notifies_on')); + } else { + event.reply(dbot.t('tripsit_already_notified')); + } + }, + + '~notripsitentries': function(event) { + if(_.include(this.tNotifies, event.rUser.id)) { + // ... + dbot.db.tNotifies = _.without(this.tNotifies, event.rUser.id); + this.tNotifies = dbot.db.tNotifies; + event.reply(dbot.t('tripsit_notifies_off')); + } else { + event.reply(dbot.t('tripsit_notifies_already_off')); + } + }, + + '~disarm': function(event) { + if(event.params[1]) { + dbot.api.users.resolveUser(event.server, event.params[1], function(err, user) { + if(user && _.has(this.tsChecks, user.id)) { + clearTimeout(this.tsChecks[user.id]); + delete this.tsChecks[user.id]; + event.reply('Disarmed ' + user.currentNick); + } else { + event.reply('No check for that user'); + } + }.bind(this)); + } + }, + + '~autodrugcategories': function(event) { + this.db.scan('drugs', function(drug) { + var summary = drug.properties.summary || ''; + if(summary.match(/psychedelic/i)) drug.categories.push('psychedelic'); + if(summary.match(/dissociative/i)) drug.categories.push('dissociative'); + if(summary.match(/opiate/i)) drug.categories.push('opioid'); + if(summary.match(/opioid/i)) drug.categories.push('opioid'); + if(summary.match(/deliriant/i)) drug.categories.push('deliriant'); + if(summary.match(/stimulant/i)) drug.categories.push('stimulant'); + if(summary.match(/depressant/i)) drug.categories.push('depressant'); + if(summary.match(/benzo/i)) drug.categories.push('benzodiazepine'); + drug.categories = _.uniq(drug.categories); + if(drug.categories.length != 0) { + this.db.save('drugs', drug.name, drug, function(){}); + } + }.bind(this), function() {}); + }, + + '~drug': function(event) { + var dName = event.input[1], + property = event.input[2]; + + this.api.getIRCFormattedDrug(dName, property, function(response) { + if(response) { + event.reply(response); + } else { + event.reply('No information for ' + dName); + } + }); + }, + + '~factsheet': function(event) { + var dName = event.params[1].toLowerCase(); + this.api.getDrug(dName, function(drug) { + if(drug) { + event.reply(dName + ': http://drugs.tripsit.me/'+drug.name); + } else { + event.reply('No data about ' + dName); + } + }); + }, + + '~setcat': function(event) { + var cName = event.input[1], + property = event.input[2].toLowerCase(), + content = event.input[3].trim(); + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrugCategory(cName, function(category) { + if(property == 'tips') return event.reply('Use ~addcattip'); + + if(category) { + this.api.setCategoryProperty(category, property, content, function() { + event.reply('Set property ' + property + ' of ' + cName); + dbot.say(event.server, '#content', dbot.t('setdrug_log', { + 'user': event.user, + 'property': property, + 'drug': cName, + 'content': content + })); + }); + } else { + event.reply('No such category.'); + } + }.bind(this)); + } + }, + + '~rmdrugsource': function(event) { + var dName = event.input[1], + property = event.input[2], + content = event.input[3].trim(); + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrug(dName, function(drug) { + if(drug && !_.has(drug, 'err')) { + if(!_.has(drug, 'sources')) { + return event.reply('Drug has no sources anyway!'); + } + if(property == 'general') { + property = '_general'; + } + property = property.toLowerCase(); + + if(_.has(drug.sources, property)) { + if(_.include(drug.sources[property], content)) { + drug.sources[property] = _.without(drug.sources[property], content); + + if(property == '_general') { + property = 'general information' + } + + this.db.save('drugs', drug.name, drug, function(err) { + event.reply('Removed source for ' + property + ' of ' + dName); + dbot.say(event.server, '#content', dbot.t('rmsource_log', { + 'user': event.user, + 'property': property, + 'drug': dName, + 'content': content + })); + }); + } else { + event.reply('Source not found.'); + } + } else { + event.reply('No sources for that property!'); + } + } else { + event.reply('No such drug!'); + } + }.bind(this)); + } + }, + + '~adddrugsource': function(event) { + var dName = event.input[1], + property = event.input[2], + content = event.input[3].trim(); + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrug(dName, function(drug) { + if(drug && !_.has(drug, 'err')) { + if(!_.has(drug, 'sources')) { + drug.sources = {}; + } + property = property.toLowerCase(); + if(property == 'general') { + property = '_general'; + } + + if(_.has(drug.properties, property) || property == '_general') { + if(!_.has(drug.sources, property)) { + drug.sources[property] = []; + } + if(_.include(drug.sources[property], content)) { + return event.reply('That source already exists!'); + } + drug.sources[property].push(content); + } else { + return event.reply('No such property, perhaps you meant to add a general source?'); + } + + if(property == '_general') { + property = 'general information' + } + + this.db.save('drugs', drug.name, drug, function(err) { + event.reply('Added source for ' + property + ' of ' + dName); + dbot.say(event.server, '#content', dbot.t('addsource_log', { + 'user': event.user, + 'property': property, + 'drug': dName, + 'content': content + })); + }); + } else { + event.reply('No such drug!'); + } + }.bind(this)); + } + }, + + '~setdrug': function(event) { + var dName = event.input[1], + property = event.input[2].toLowerCase(), + content = event.input[3].trim(); + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + if(property == '_general') { + return event.reply('Reserved property name, please choose another'); + } + this.api.getDrug(dName, function(drug) { + if(property == 'aliases') return event.reply('Use ~setdrugalias'); + if(property == 'categories') return event.reply('Use ~addrugcategory or ~rmdrugcategory'); + if(drug && !_.has(drug, 'err')) { + this.api.setDrugProperty(drug, property, content, function() { + event.reply('Set property ' + property + ' of ' + dName); + dbot.say(event.server, '#content', dbot.t('setdrug_log', { + 'user': event.user, + 'property': property, + 'drug': dName, + 'content': content + })); + }); + } else { + this.api.createDrug(dName, function() { + this.commands['~setdrug'](event); + }.bind(this)); + } + }.bind(this)); + } + }, + + '~drugs': function(event) { + this.commands['~drug'](event); + }, + + '~setdrugprettyname': function(event) { + var dName = event.input[1].toLowerCase(), + aName = event.input[2]; + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrug(dName, function(drug) { + if(drug) { + drug.pretty_name = aName; + this.db.save('drugs', drug.name, drug, function() {}); + event.reply(aName + ' is now they pretty name of ' + dName); + dbot.say(event.server, '#content', dbot.t('setdrug_log', { + 'user': event.user, + 'property': 'pretty name', + 'drug': dName, + 'content': aName + })); + } else { + event.reply('No such drug.'); + } + }.bind(this)); + } + }, + + + '~setdrugcategory': function(event) { + var dName = event.input[1].toLowerCase(), + aName = event.input[2].toLowerCase(); + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + var availableCategories = [ 'psychedelic', 'benzodiazepine', + 'dissociative', 'opioid', 'depressant', 'common', 'barbiturate', 'supplement', 'stimulant', 'habit-forming', 'research-chemical', 'empathogen', 'deliriant', 'nootropic', 'tentative', 'ssri', 'maoi', 'inactive' ]; + if(_.include(availableCategories, aName)) { + this.api.getDrug(dName, function(drug) { + if(drug) { + if(!_.include(drug.categories, aName)) { + if(!_.has(drug, 'categories')) { + drug.categories = []; + } + drug.categories.push(aName); + this.db.save('drugs', drug.name, drug, function() {}); + event.reply(aName + ' is now an category of ' + dName); + dbot.say(event.server, '#content', dbot.t('setdrug_log', { + 'user': event.user, + 'property': 'category', + 'drug': dName, + 'content': aName + })); + } else { + event.reply(aName + ' is already a category of ' + dName); + } + } else { + event.reply('No such drug.'); + } + }.bind(this)); + } else { + event.reply('Nah mate, available drug categories are: ' + + availableCategories.join(', ')); + } + } + }, + + '~rmdrugcategory': function(event) { + var dName = event.input[1].toLowerCase(), + aName = event.input[2].toLowerCase(); + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrug(dName, function(drug) { + if(drug) { + if(_.include(drug.categories, aName)) { + drug.categories = _.without(drug.categories, aName); + this.db.save('drugs', drug.name, drug, function() {}); + event.reply(aName + ' is no longer a category of ' + dName); + dbot.say(event.server, '#content', dbot.t('rmdrugproperty_log', { + 'user': event.user, + 'property': 'category ' + aName, + 'drug': dName, + 'content': aName + })); + + } else { + event.reply(aName + ' isn\'t category of ' + dName); + } + } else { + event.reply('No such drug.'); + } + }.bind(this)); + } + }, + + '~rmdrugalias': function(event) { + var dName = event.input[1].toLowerCase(), + aName = event.input[2].toLowerCase(); + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrug(dName, function(drug) { + if(drug) { + if(_.include(drug.aliases, aName)) { + drug.aliases = _.without(drug.aliases, aName); + this.db.save('drugs', drug.name, drug, function() {}); + event.reply(aName + ' is no longer an alias of ' + dName); + dbot.say(event.server, '#content', dbot.t('rmdrugproperty_log', { + 'user': event.user, + 'property': 'alias ' + aName, + 'drug': dName, + 'content': aName + })); + + } else { + event.reply(aName + ' isn\'t an alias of ' + dName); + } + } else { + event.reply('No such drug.'); + } + }.bind(this)); + } + }, + + '~addcattip': function(event) { + var cat = event.input[1], + tip = event.input[2]; + + this.api.getDrugCategory(cat, function(category) { + if(category) { + category.tips.push(tip); + this.db.save('drug_categories', category.name, category, function() { + event.reply('Added tip to ' + cat); + + dbot.say(event.server, '#content', dbot.t('setdrug_log', { + 'user': event.user, + 'property': 'tip', + 'drug': cat, + 'content': tip + })); + }); + } else { + event.reply('No such drug category.'); + } + }.bind(this)); + }, + + '~rmcattip': function(event) { + var cat = event.input[1], + tip = event.input[2]; + + this.api.getDrugCategory(cat, function(category) { + if(category) { + var len = category.tips.length; + category.tips = _.without(category.tips, tip); + + if(len != category.tips.length) { + this.db.save('drug_categories', category.name, category, function() { + event.reply('Removed tip from ' + cat); + + dbot.say(event.server, '#content', dbot.t('rmdrugproperty_log', { + 'user': event.user, + 'property': 'tip', + 'drug': cat, + })); + }); + } else { + event.reply('Tip not found'); + } + } else { + event.reply('No such drug category.'); + } + }.bind(this)); + }, + + '~setdrugalias': function(event) { + var dName = event.input[1].toLowerCase(), + aName = event.input[2].toLowerCase(); + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrug(dName, function(drug) { + if(drug && !_.has(drug, 'err')) { + this.api.getDrug(aName, function(aDrug) { + if(!aDrug || _.has(aDrug, 'err')) { + if(!_.has(drug, 'aliases')) { + drug.aliases = []; + } + drug.aliases.push(aName); + this.db.save('drugs', drug.name, drug, function() {}); + event.reply(aName + ' is now an alias of ' + dName); + } else { + event.reply(aName + ' is already recorded as a drug.'); + } + }.bind(this)); + } else { + event.reply('No such drug.'); + } + }.bind(this)); + } + }, + + '~setdrugaliasparent': function(event) { + var dName = event.params[1].toLowerCase(); + + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrug(dName, function(drug) { + if(drug) { + if(_.include(drug.aliases, dName)) { + this.api.delDrug(drug.name, function() { + drug.aliases.push(drug.name); + drug.name = dName; + drug.aliases = _.without(drug.aliases, dName); + this.db.save('drugs', dName, drug, function() { + event.reply(dName + ' is now parent.'); + }); + }.bind(this)); + } else { + event.reply('Not even an alias.'); + } + } else { + event.reply('No such drug.'); + } + }.bind(this)); + } + }, + + '~rmdrug': function(event) { + var dName = event.params[1], + pName = event.params[2]; + + // I'm sorry Jesus + var allowedUsers = _.union(dbot.config.admins, + dbot.config.moderators, dbot.config.power_users, + this.config.tripsitters); + + if(_.include(allowedUsers, event.rUser.primaryNick)) { + this.api.getDrug(dName, function(drug) { + if(drug) { + if(_.isUndefined(pName)) { + this.api.delDrug(dName, function() { + event.reply('Removed ' + dName + ' from drugs.'); + dbot.say(event.server, '#content', dbot.t('rmdrug_log', { + 'user': event.user, + 'drug': dName + })); + }); + } else { + pName = pName.trim(); + if(_.has(drug.properties, pName)) { + this.api.delDrugProperty(drug, pName, function() { + event.reply(pName + ' removed from ' + dName); + dbot.say(event.server, '#content', dbot.t('rmdrugproperty_log', { + 'user': event.user, + 'drug': dName, + 'property': pName + })); + }); + } else { + event.reply('No such property in ' + drug.name); + } + } + } else { + event.reply('No such drug.'); + } + }.bind(this)); + } + }, + + '~bdiaz': function(event) { + var benzo = event.params[1].toLowerCase(), + amount = event.params[2].replace('mg', ''); + + if(_.has(this.bTable, benzo)) { + var diazepam = (amount / this.bTable[benzo]) * 10; + event.reply(event.params[2] + ' ' + benzo + ' ~= ' + diazepam + 'mg diazepam.'); + } else { + event.reply(event.params[1] + ' not found.'); + } + }, + + '~bconvert': function(event) { + var sAmount = event.params[1].replace('mg', ''), + bSource = event.params[2], + bTarget = event.params[3]; + + if(_.has(this.bTable, bSource) && _.has(this.bTable, bTarget)) { + var sDiaz = (sAmount / this.bTable[bSource]) * 10, + tDiaz = (this.bTable[bTarget] / this.bTable[bTarget]) * 10, + conv = (sDiaz / tDiaz) * this.bTable[bTarget]; + event.reply(sAmount + 'mg ' + bSource + ' ~= ' + conv + 'mg ' + bTarget); + } else { + event.reply('Unknown benzos.'); + } + }, + + '~staffstatus': function(event) { + var target = (event.params[1] || event.user).trim(); + dbot.api.users.resolveUser(event.server, target, function(err, user) { + if(!err && user) { + dbot.api.nickserv.getUserHost(event.server, user.primaryNick, function(host) { + if(host) { + var position = host.split('/')[1]; + if(position) { + event.reply(user.primaryNick + ' is ' + position); + + if(position != 'user') { + dbot.api.sstats.getUserStats(user.id, function(uStats) { + if(uStats && uStats.last) { + event.reply(user.primaryNick + ' was last active in a public channel ' + moment(uStats.last).fromNow()); + } + var lastTripsitNotify = null, + lastTripsitTime = 0, + lastModNotify = null, + lastModTime = 0; + + dbot.modules.report.db.search('notifies', { + 'server': event.server + }, function(notify) { + if(notify.channel == '#tripsit' && notify.message.match(user.primaryNick) && notify.time > lastTripsitTime) { + lastTripsitNotify = notify; + lastTripsitTime = notify.time; + } + if((notify.type == 'quiet' || notify.type == 'ban' || notify.type == 'warn') && notify.user == user.id && notify.time > lastModTime) { + lastModNotify = notify; + lastModTime = notify.time; + } + }, function() { + if(lastTripsitTime != 0) { + event.reply(user.primaryNick + ' was last tagged in a #tripsit notify ' + moment(lastTripsitTime).fromNow()); + } else { + event.reply('Can\'t find the last time the ' + user.primaryNick + ' was tagged in a #tripsit notify.'); + } + if(lastModTime != 0) { + var what; + if(lastModNotify.type == 'quiet') { + what = 'quieted ' + lastModNotify.message.match(/quieted ([^ \.]+)/)[1] + ' in ' + lastModNotify.channel; + } else if(lastModNotify.type == 'warn') { + what = 'warned ' + lastModNotify.message.match(/warning to ([^ \.]+)/)[1]; + } else if(lastModNotify.type == 'ban') { + if(lastModNotify.message.match(/AKilled/)) { + what = 'special-k-lined ' + lastModNotify.message.split(' ')[0]; + } else { + what = 'banned ' + lastModNotify.message.match(/banned ([^ ]+)/)[1]; + } + } + + event.reply(user.primaryNick + ' last performed a mod action ' + moment(lastModTime).fromNow() + ' ('+what+')'); + } else if(position != 'tripsitter') { + event.reply('Can\'t find the last time the ' + user.primaryNick + ' performed a mod action.'); + } + }); + }); + } + } else { + event.reply(user.primaryNick + ' does not seem to be registered!'); + } + } else { + event.reply('Can\'t find a hostmask for ' + user.primaryNick); + } + }); + } else { + event.reply('no idea who that is m8.'); + } + }); + }, + + '~oconvert': function(event) { + var sAmount = event.params[1].replace('mg', ''), + sRoa = event.params[2].toLowerCase(), + oSource = event.params[3].toLowerCase(), + tRoa = event.params[4].toLowerCase(), + oTarget = event.params[5].toLowerCase(); + + if(_.has(this.opiates, oSource) && _.has(this.opiates, oTarget) && _.has(this.opiates[oTarget].ba, tRoa)) { + // Work out the amount of morphine is equivalent to sAmount of oSource + + if(sRoa == 'iv') { + var sMorphRoa = (sAmount / this.opiates[oSource].toMorphine) * 10; + } else { + var sMorphRoa = (this.opiates[oSource].ba[sRoa]/10)*sAmount/10; + } + //var sMorphRoa = 10*sMorph/(this.opiates[oSource].ba[sRoa]/10); + + // Work out the amount of oTarget is equivalent to that amount of morphine at 100% + var tMorph = (this.opiates[oTarget].toMorphine / this.opiates[oTarget].toMorphine) * 10; + + var conv = (sMorphRoa / tMorph) * this.opiates[oTarget].toMorphine; + + + // Work out the amount of oTarget that is equivalent to that amount of morphine at x% + // 10m/0.9 = r + event.reply(sAmount + 'mg ' + sRoa + ' ' + oSource + ' ~= ' + (10*conv/(this.opiates[oTarget].ba[tRoa]/10)).toFixed(2) + 'mg ' + tRoa + ' ' + oTarget + + ' [BETA][Note: Equianalgesic conversions are given as a guideline and cannot be entirely trusted. Effects, onset etc may differ between drugs and ROA.]'); + + + } else { + event.reply('Unknown opiates or roas.'); + } + }, + + '~combo': function(event) { + var d1 = event.input[1].toLowerCase(), + d2 = event.input[2].toLowerCase(); + + this.api.getInteraction(d1, d2, function(res) { + if(res && !_.has(res, 'err')) { + var output = res.interactionCategoryA + ' + ' + res.interactionCategoryB + ': ' + res.status; + if(_.has(res, 'note')) { + output += '. ' + res.note; + } + event.reply(output); + } else { + if(res.code == 'ssb') { + event.reply('Combination of benzos may unpredictably increase the intensity of undesirable effects.'); + } else if(res.code == 'ssc') { + event.reply('Drugs are of the same safety category.'); + } else { + event.reply('Unknown combo (that doesn\'t mean it\'s safe). Known combos: ' + + _.keys(this.combos).join(', ') + '.'); + } + } + }.bind(this)); + }, + + '~volume': function(event) { + var total = event.input[1], + perml = event.input[2]; + + event.reply('For a solution with ' + perml + 'mg/ml, add ' + total + 'mg to ' + (total/perml) + 'ml.'); + }, + + '~perml': function(event) { + var material = event.input[1], + liquid = event.input[2]; + + event.reply('If you put ' + material + 'mg in ' + liquid + 'ml of solution, it will be ' + (material / liquid) + 'mg/ml.'); + } + }; + this.commands = commands; + this.commands['~nstats'].regex = [/^nstats ([\d\w\-]+[\d\w\s\-]*)[ ]?=[ ]?(.+)$/, 3]; + this.commands['~drug'].regex = /^drug ([^ ]+) ?(.+)?$/; + this.commands['~setdrugalias'].regex = /^setdrugalias ([^ ]+) ([^ ]+)/; + this.commands['~combo'].regex = /^combo ([^ ]+) ([^ ]+)/; + this.commands['~volume'].regex = /^volume ([^ ]+) ([^ ]+)/; + this.commands['~perml'].regex = /^perml ([^ ]+) ([^ ]+)/; + this.commands['~wiki'].regex = [/^wiki (.+)/, 2]; + this.commands['~setdrugcategory'].regex = /^setdrugcategory ([^ ]+) ([^ ]+)/; + this.commands['~addcattip'].regex = /^addcattip ([^ ]+) (.+)/; + this.commands['~rmcattip'].regex = /^rmcattip ([^ ]+) (.+)/; + this.commands['~setdrugprettyname'].regex = /^setdrugprettyname ([^ ]+) (.+)/; + this.commands['~rmdrugcategory'].regex = /^rmdrugcategory ([^ ]+) ([^ ]+)$/; + this.commands['~rmdrugalias'].regex = /^rmdrugalias ([^ ]+) ([^ ]+)$/; + this.commands['~setdrug'].regex = [/^setdrug ([^ ]+) ([^ ]+) (.+)$/, 4]; + this.commands['~adddrugsource'].regex = [/^adddrugsource ([^ ]+) ([^ ]+) (.+)$/, 4]; + this.commands['~rmdrugsource'].regex = [/^rmdrugsource ([^ ]+) ([^ ]+) (.+)$/, 4]; + this.commands['~setcat'].regex = [/^setcat ([^ ]+) ([^ ]+) (.+)$/, 4]; + this.commands['~staffstatus'].access = 'moderator'; + + this.onLoad = function() { +/* dbot.commands['~quiet'].access = function(event) { + if(event.channel == '#tripsit' || event.channel == '#sanctuary' || event.channel == '#stims' || event.channel == '#opiates' || event.channel == '##meth') { + return dbot.access.voice(event); + } else if(event.channel == '##wat'){ + return dbot.access.op(event); + } else { + return dbot.access.power_user(event); + } + }.bind(this); +/* dbot.commands['~unquiet'].access = function(event) { + if(event.channel == '#tripsit' || event.channel == '#sanctuary' || event.channel == '#stims' || event.channel == '#opiates' || event.channel == '##meth') { + return dbot.access.voice(event); + } else if(event.channel == '##wat'){ + return dbot.access.op(event); + } else { + return dbot.access.power_user(event); + } + }.bind(this); */ + + + dbot.api.event.addHook('new_notify', function(notify, user) { + if(user == 'thanatos' && notify.type == 'quiet') { + var curTime = new Date().getTime(); + if(curTime - dbot.db.lastAutoquiet.time > dbot.db.autoQuietHighscore) { + event.reply('New autoquiet highscore! We went ' + moment(curTime).from(dbot.db.lastAutoquiet, true) + ', beating the previous record of ' + moment.duration(dbot.db.autoQuietHighscore) + '!'); + dbot.db.autoQuietHighscore = curTime - dbot.db.lastAutoquiet.time; + } + dbot.db.lastAutoquiet = { 'time': curTime, 'lastDuration': curTime - dbot.db.lastAutoquiet.time, 'quietee': notify.target, 'channel': notify.channel }; + } + }); + + dbot.api.event.addHook('new_user', function(user) { + if(_.has(dbot.instance.connections.tripsit.channels, '#drugs')) { + setTimeout(function() { + dbot.api.nickserv.auth(user.server, user.currentNick, function(result, primary) { + if(result === false) { + var nicks = []; + async.each(this.tNotifies, function(id, done) { + dbot.api.users.getUser(id, function(err, user) { + if(user) { + nicks.push(user.currentNick); + } + done(false); + }); + }, function() { + var type = '\u00033tripsit\u000f'; + dbot.api.report.notifyUsers(user.server, nicks, + dbot.t('new_tripsit_user', { 'type': type, 'user': user.currentNick })); + + dbot.api.event.emit('new_tripsit_user', [ user ]); + + // Add a check + dbot.api.users.resolveUser(user.server, dbot.config.name, function(err, bot) { + /*setTimeout(function() { + dbot.api.event.emit('new_tripsit_user_finished', [ user ]); + }, 900000);*/ + this.tsChecks[user.id] = setTimeout(function() { + //dbot.api.report.notify('tripsit', user.server, bot, + // '#teamtripsit', 'No #tripsit notification observed for ' + + // user.currentNick); + dbot.api.event.emit('tripsit_no_notify', [ user ]); + delete this.tsChecks[user.id]; + }.bind(this), 600000); + }.bind(this)); + }.bind(this)); + } + }.bind(this)); + }.bind(this), 10000); + } + }.bind(this)); + + dbot.api.event.addHook('new_warning', function(warner, warnee, reason) { + if(reason.match('#note')) { + return; + } + var count = 0; + var source_count = 0; + dbot.modules.warning.db.search('warnings', { 'warnee': warnee.id }, function(warn) { + if(!warn.reason.match('#note')) { + count++; + if(warn.reason.match('source') || warn.reason.match('sourcing')) { + source_count++; + } + } + }, function() { + if(source_count > 1) { + dbot.say('tripsit', '#tripsit.me', warner.currentNick + ': ' + + warnee.primaryNick + ' has been warned for sourcing ' + source_count + ' times. ' + + ' Maybe it\'s time for a holiday?'); + } + if(count > 2) { + dbot.say('tripsit', '#tripsit.me', warner.currentNick + ': ' + + warnee.primaryNick + ' has been warned a total of ' + count + ' times. ' + + ' Maybe it\'s time for a holiday?'); + } + }); + }); + + dbot.api.event.addHook('new_notify', function(notify, creator) { + _.each(_.keys(this.tsChecks), function(id) { + dbot.api.users.getUser(id, function(err, user) { + if(user) { + if(notify.message.match(escapeRegExp(user.primaryNick)) != null || notify.message.match(escapeRegExp(user.currentNick)) != null) { + clearTimeout(this.tsChecks[id]); + delete this.tsChecks[id]; + } + } + }.bind(this)); + }.bind(this)); + + if(notify.channel === '#tripsit') { + var nick = notify.message.split(' ')[0]; + if(_.include(this.recentNotifies, nick) && notify.message.indexOf('#update') == -1) { + dbot.modules.report.db.del('notifies', notify.id, function(){}); + dbot.say('tripsit', '#teamtripsit', dbot.t('deleted_dupe', { + 'alias': nick, + 'creator': creator + })); + } else { + this.recentNotifies.push(nick); + setTimeout(function() { + this.recentNotifies = _.without(this.recentNotifies, nick); + }.bind(this), 1800000); + } + } + + }.bind(this)); + + if(_.has(dbot.modules, 'web')) { + dbot.api.web.addIndexLink('/factsheet', 'Factsheets'); + } + }.bind(this); + + this.listener = function(event) { + if(event.action == '322') { + var split = event.params.split(' '); + split[1] = split[1].replace(/(>|<)/g, ''); + this.channels.push([ split[2], split[1] ]); + this.channels = _.sortBy(this.channels, function(el) { return parseInt(el[0]); }); + } + }.bind(this); + this.on = ['322', 'PRIVMSG']; +}; + +exports.fetch = function(dbot) { + return new tripsit(dbot); +}; diff --git a/tripsit/usage.json b/tripsit/usage.json new file mode 100644 index 0000000..9d317f5 --- /dev/null +++ b/tripsit/usage.json @@ -0,0 +1,7 @@ +{ + "~setdrug": "~setdrug [drugname] [propertyname] [content here]", + "~rmdrug": "~rmdrug [drugname] (propertyname)", + "~volume": "~volume [total material in mg] [target mg of material per ml]", + "~perml": "~perml [total material in mg] [ml of solution]", + "~oconvert": "~oconvert [amount]mg [sourceDrug] [targetROA] [targetDrug]" +} diff --git a/tripsit/views/factsheet.jade b/tripsit/views/factsheet.jade new file mode 100644 index 0000000..8d157b7 --- /dev/null +++ b/tripsit/views/factsheet.jade @@ -0,0 +1,32 @@ +extends ../layout + +block content + p.text1 + u + b ↳ + a(href='/') Index + > + a(href='/factsheet') Factsheets + > #{drug.name} + table.table1 + thead + tr + th.theader(style='width: 25%;') + | #{drug.name} + th.theader(style='width: 75%;') + | Info + table.table2 + tbody.tbody1 + for property, name in drug.properties + - name = name.charAt(0).toUpperCase() + name.slice(1); + tr + td.tlefttext(style='width: 25%;') + b #{name} + td.ttext(style='width: 75%;') + - if (typeof(property) === 'string'){ + | #{property} + -} else { + -each line in property + | #{line} + br + -} diff --git a/tripsit/views/fs_list.jade b/tripsit/views/fs_list.jade new file mode 100644 index 0000000..81f4137 --- /dev/null +++ b/tripsit/views/fs_list.jade @@ -0,0 +1,48 @@ +extends ../layout + +block content + script(type="text/javascript", src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js") + p.text1 + u + b ↳ + a(href='/') Index + > Factsheets + p + + table.table1 + thead + tr + th.theader(style='width: 30%;') + | Name + th.theader(style='width: 70%;') + | Summary + table.table2 + tbody.tbody1 + -each drug in drugs + tr + td.ttext(style='width: 30%;') + a.boxed2(href='/factsheet/'+drug.name) + | #{drug.name} + if drug.categories + each kw in drug.categories + if kw == 'psychedelic' + span.label.label-warning(style='float:right;padding:3px;margin-right:5px;' data-placement="right") #{kw} + else if kw == 'benzodiazepine' + span.label.label-danger(style='background-color:#000;color:#FF0000;float:right;padding:3px;margin-right:5px;' data-placement="right") benzo + else if kw == 'stimulant' + span.label.label-info(style='float:right;padding:3px;margin-right:5px;' data-placement="right") stimulant + else if kw == 'dissociative' + span.label.label-default(style='background-color:purple;color:white;float:right;padding:3px;margin-right:5px;' data-placement="right") dissociative + else if kw == 'opioid' + span.label.label-success(style='float:right;padding:3px;margin-right:5px;' data-placement="right") opioid + else if kw == 'depressant' + span.label.label-danger(style='float:right;padding:3px;margin-right:5px;' data-placement="right") depressant + else + span.label.label-default(style='float:right;padding:3px;margin-right:5px;' data-placement="right") other + else + span.label.label-default(style='float:right;padding:3px;margin-right:5px;' data-placement="right") other + td.ttext(style='width: 70%;') + | #{drug.properties.summary} + p + p + b Factsheets on #{drugs.length} drugs diff --git a/tripsit/views/tripsit/factsheet.jade b/tripsit/views/tripsit/factsheet.jade new file mode 100644 index 0000000..8d157b7 --- /dev/null +++ b/tripsit/views/tripsit/factsheet.jade @@ -0,0 +1,32 @@ +extends ../layout + +block content + p.text1 + u + b ↳ + a(href='/') Index + > + a(href='/factsheet') Factsheets + > #{drug.name} + table.table1 + thead + tr + th.theader(style='width: 25%;') + | #{drug.name} + th.theader(style='width: 75%;') + | Info + table.table2 + tbody.tbody1 + for property, name in drug.properties + - name = name.charAt(0).toUpperCase() + name.slice(1); + tr + td.tlefttext(style='width: 25%;') + b #{name} + td.ttext(style='width: 75%;') + - if (typeof(property) === 'string'){ + | #{property} + -} else { + -each line in property + | #{line} + br + -} diff --git a/tripsit/views/tripsit/fs_list.jade b/tripsit/views/tripsit/fs_list.jade new file mode 100644 index 0000000..81f4137 --- /dev/null +++ b/tripsit/views/tripsit/fs_list.jade @@ -0,0 +1,48 @@ +extends ../layout + +block content + script(type="text/javascript", src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js") + p.text1 + u + b ↳ + a(href='/') Index + > Factsheets + p + + table.table1 + thead + tr + th.theader(style='width: 30%;') + | Name + th.theader(style='width: 70%;') + | Summary + table.table2 + tbody.tbody1 + -each drug in drugs + tr + td.ttext(style='width: 30%;') + a.boxed2(href='/factsheet/'+drug.name) + | #{drug.name} + if drug.categories + each kw in drug.categories + if kw == 'psychedelic' + span.label.label-warning(style='float:right;padding:3px;margin-right:5px;' data-placement="right") #{kw} + else if kw == 'benzodiazepine' + span.label.label-danger(style='background-color:#000;color:#FF0000;float:right;padding:3px;margin-right:5px;' data-placement="right") benzo + else if kw == 'stimulant' + span.label.label-info(style='float:right;padding:3px;margin-right:5px;' data-placement="right") stimulant + else if kw == 'dissociative' + span.label.label-default(style='background-color:purple;color:white;float:right;padding:3px;margin-right:5px;' data-placement="right") dissociative + else if kw == 'opioid' + span.label.label-success(style='float:right;padding:3px;margin-right:5px;' data-placement="right") opioid + else if kw == 'depressant' + span.label.label-danger(style='float:right;padding:3px;margin-right:5px;' data-placement="right") depressant + else + span.label.label-default(style='float:right;padding:3px;margin-right:5px;' data-placement="right") other + else + span.label.label-default(style='float:right;padding:3px;margin-right:5px;' data-placement="right") other + td.ttext(style='width: 70%;') + | #{drug.properties.summary} + p + p + b Factsheets on #{drugs.length} drugs