Init
Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
commit
03326d7d78
11
README.md
Normal file
11
README.md
Normal file
@ -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.
|
129
idose/idose.js
Normal file
129
idose/idose.js
Normal file
@ -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;
|
||||
}
|
1
tripsit/INSTALL
Normal file
1
tripsit/INSTALL
Normal file
@ -0,0 +1 @@
|
||||
Move views/tripsit to dbot /views/tripsit
|
565
tripsit/api.js
Normal file
565
tripsit/api.js
Normal file
@ -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);
|
||||
};
|
755
tripsit/combo.json
Normal file
755
tripsit/combo.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
6
tripsit/config.json
Normal file
6
tripsit/config.json
Normal file
@ -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 ="
|
||||
}
|
184
tripsit/pages.js
Normal file
184
tripsit/pages.js
Normal file
@ -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);
|
||||
};
|
53
tripsit/strings.json
Normal file
53
tripsit/strings.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
1
tripsit/tripsit
Submodule
1
tripsit/tripsit
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 3f952b039098db61c7fbeaf3a2b4140f12b0738a
|
1175
tripsit/tripsit.js
Normal file
1175
tripsit/tripsit.js
Normal file
File diff suppressed because it is too large
Load Diff
7
tripsit/usage.json
Normal file
7
tripsit/usage.json
Normal file
@ -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]"
|
||||
}
|
32
tripsit/views/factsheet.jade
Normal file
32
tripsit/views/factsheet.jade
Normal file
@ -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
|
||||
-}
|
48
tripsit/views/fs_list.jade
Normal file
48
tripsit/views/fs_list.jade
Normal file
@ -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
|
32
tripsit/views/tripsit/factsheet.jade
Normal file
32
tripsit/views/tripsit/factsheet.jade
Normal file
@ -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
|
||||
-}
|
48
tripsit/views/tripsit/fs_list.jade
Normal file
48
tripsit/views/tripsit/fs_list.jade
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user