mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 22:39:26 +01:00
Merge branch 'master' of github.com:reality/depressionbot
This commit is contained in:
commit
023c689f65
@ -11,8 +11,8 @@ var api = function(dbot) {
|
||||
if(!_.has(this.profiles, server)){
|
||||
this.profiles[server] = {};
|
||||
}
|
||||
this.profiles[server][primary] = {};
|
||||
_.defaults(this.profiles[server][primary], this.config.schema);
|
||||
this.profiles[server][primary.toLowerCase()] = {};
|
||||
_.defaults(this.profiles[server][primary.toLowerCase()], this.config.schema);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,8 @@ var commands = function(dbot){
|
||||
|
||||
"~getprop": function(event){
|
||||
if(event.params[1]){
|
||||
var res = dbot.db.profiles[event.server][event.user.toLowerCase()].profile[event.params[1]];
|
||||
var primary = dbot.api.users.resolveUser(event.server, event.user);
|
||||
var res = dbot.db.profiles[event.server][primary.toLowerCase()].profile[event.params[1]];
|
||||
if(res){
|
||||
event.reply(res);
|
||||
}
|
||||
@ -18,13 +19,32 @@ var commands = function(dbot){
|
||||
"~setprop": function(event){
|
||||
if(event.input[1] && event.input[2]){
|
||||
if(_.has(this.config.schema.profile, event.input[1])){
|
||||
dbot.db.profiles[event.server][event.user.toLowerCase()].profile[event.input[1]] = event.input[2];
|
||||
var primary = dbot.api.users.resolveUser(event.server, event.user);
|
||||
dbot.db.profiles[event.server][primary.toLowerCase()].profile[event.input[1]] = event.input[2];
|
||||
event.reply("Property set, maybe?");
|
||||
}
|
||||
else{
|
||||
event.reply("Invalid property. Go home.");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"~profile": function(event){
|
||||
if(event.params[1]){
|
||||
var primary = dbot.api.users.resolveUser(event.server, event.params[1]);
|
||||
if(_.has(dbot.db.profiles[event.server], primary.toLowerCase())){
|
||||
event.reply("http://"+dbot.config.web.webHost+":"+dbot.config.web.webPort+"/profile/"+event.server+"/"+primary.toLowerCase());
|
||||
}
|
||||
else{
|
||||
event.reply("No profile found for "+event.params[1]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
event.message = '~profile ' + event.user;
|
||||
event.action = 'PRIVMSG';
|
||||
event.params = event.message.split(' ');
|
||||
dbot.instance.emit(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
commands['~setprop'].regex = [/~setprop ([^ ]+) (.+)/, 3];
|
||||
|
@ -17,5 +17,5 @@
|
||||
"timezone": null
|
||||
}
|
||||
},
|
||||
"dependencies": [ "quotes", "command" ]
|
||||
"dependencies": [ "quotes", "users", "command" ]
|
||||
}
|
||||
|
@ -33,6 +33,10 @@ var profile = function(dbot) {
|
||||
});
|
||||
});
|
||||
dbot.save();
|
||||
|
||||
// Add API Hooks
|
||||
dbot.api.command.addHook('~setaliasparent', this.api.renameProfile);
|
||||
dbot.api.command.addHook('~mergeusers', this.api.mergeProfile);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -28,11 +28,17 @@ var pages = function(dbot) {
|
||||
|
||||
var chanData = dbot.api.stats.getChanStats(connection, channel, ["freq"]);
|
||||
var chanFreq = [];
|
||||
|
||||
if(chanData){
|
||||
for(var i=0; i <= 6; i++){
|
||||
for(var j=0; j <= 23; j++){
|
||||
chanFreq.push(chanData.fields.freq.raw[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
for (var i = 0; i < 168; i++) chanFreq[i] = 0;
|
||||
}
|
||||
|
||||
var userData = { "active": [], "inactive": [], "offline": []};
|
||||
var reply = dbot.api.stats.getChanUsersStats(connection, channel, [
|
||||
|
@ -71,6 +71,7 @@ block content
|
||||
th Verbosity
|
||||
th Mentions
|
||||
tbody
|
||||
if stats
|
||||
for chan, key in stats
|
||||
if stats.hasOwnProperty(key)
|
||||
tr
|
||||
|
@ -9,10 +9,16 @@ block content
|
||||
.chart rect:hover {
|
||||
fill: #000;
|
||||
}
|
||||
.yTicks {
|
||||
stroke: #aaa;
|
||||
stroke-width: 0.5;
|
||||
}
|
||||
|
||||
script
|
||||
$(document).ready(function(){
|
||||
// d3.js Graph
|
||||
var xlab = 30;
|
||||
var chartw = 940;
|
||||
var w = 5.595;
|
||||
var h = 120;
|
||||
|
||||
@ -21,13 +27,22 @@ block content
|
||||
.range([0,w]);
|
||||
|
||||
var y = d3.scale.linear()
|
||||
.domain([0,100])
|
||||
.domain([0,d3.max([#{chanFreq}])])
|
||||
.rangeRound([0,h]);
|
||||
|
||||
var chart = d3.select($("#chanFreqChart")[0]).append("svg")
|
||||
.attr("class", "chart")
|
||||
.attr("width", w * #{chanFreqLen} - 1)
|
||||
.attr("height", h);
|
||||
.attr("height", h + xlab);
|
||||
|
||||
chart.selectAll(".yTicks")
|
||||
.data(y.ticks(5).slice(1,5))
|
||||
.enter().append("svg:line")
|
||||
.attr("class", "yTicks")
|
||||
.attr("y1", function(d) { return -1 * y(d) + h; })
|
||||
.attr("x1", 0)
|
||||
.attr("y2", function(d) { return -1 * y(d) + h; })
|
||||
.attr("x2", w * #{chanFreqLen})
|
||||
|
||||
chart.selectAll("rect")
|
||||
.data([#{chanFreq}])
|
||||
@ -36,7 +51,18 @@ block content
|
||||
.attr("y", function(d) { return h - y(d) - .5; })
|
||||
.attr("width", w)
|
||||
.attr("height", function(d) { return y(d); })
|
||||
.attr("title", function(d){ return y(d); });
|
||||
.attr("title", function(d){ return d; });
|
||||
|
||||
chart.selectAll(".rule")
|
||||
.data(y.ticks(5).slice(1,5))
|
||||
.enter().append("text")
|
||||
.attr("class", "rule")
|
||||
.attr("y", function(d) { return -1 * y(d) + h; })
|
||||
.attr("x", (chartw / 2)+(w/2))
|
||||
.attr("text-anchor", "middle")
|
||||
.attr("font-size", 10)
|
||||
.attr("dy", 3)
|
||||
.text(String);
|
||||
|
||||
chart.append("line")
|
||||
.attr("x1", 0)
|
||||
@ -45,6 +71,26 @@ block content
|
||||
.attr("y2", h - .5)
|
||||
.style("stroke", "#000");
|
||||
|
||||
chart.selectAll("text.times")
|
||||
.data(["0", "6", "12", "18","0", "6", "12", "18","0", "6", "12", "18","0", "6", "12", "18" ,"0", "6", "12", "18" ,"0", "6", "12", "18" ,"0", "6", "12", "18"])
|
||||
.enter().append("text")
|
||||
.attr("x", function(d, i){ return ((i * w * 6)+(w/2)); })
|
||||
.attr("y", h + 10)
|
||||
.attr("text-anchor", "middle")
|
||||
.attr('class', 'name')
|
||||
.attr("font-size", 10)
|
||||
.text(String);
|
||||
|
||||
chart.selectAll("text.days")
|
||||
.data(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"])
|
||||
.enter().append("text")
|
||||
.attr("x", function(d, i){ return ((i+0.5) * w * 24); })
|
||||
.attr("y", h + 25)
|
||||
.attr("text-anchor", "middle")
|
||||
.attr('class', 'name')
|
||||
.attr("font-size", 12)
|
||||
.text(String);
|
||||
|
||||
|
||||
// Allowing forcing of string stats data to sort as numeric
|
||||
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
|
||||
|
Loading…
Reference in New Issue
Block a user