Skip to content

Commit c1e17a1

Browse files
Dean SoferDean Sofer
Dean Sofer
authored and
Dean Sofer
committed
Fixed webserver side of plugin
1 parent e11361b commit c1e17a1

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
<div class="karma">
1+
<div class="karma" ng-init="karmas=(toArray(plugin.karma)|orderBy:'value':true)">
22
<ul>
33
<li><strong>Add Karma:</strong> <code>[nick]++</code></li>
44
<li><strong>Remove Karma:</strong> <code>[nick]--</code></li>
55
<li><strong>Check Karma:</strong> <code>!karma [nick]</code> [nick] is optional (returns your own karma)</li>
66
</ul>
7-
<form class="form-group">
7+
<form class="form-group" ng-init="filter=''">
88
<div class="input-group">
99
<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
1010
<input class="form-control" ng-model="filter" placeholder="Filter" type="search">
1111
</div>
1212
</form>
13-
<dl class="dl-horizontal" ng-repeat="karma in karmas | orderBy: 'value': true | filter: {key:filter}">
13+
<dl class="dl-horizontal" ng-repeat="karma in karmas | filter: filter track by $index">
1414
<dt>{{karma.key}}:</dt> <dd>{{karma.value}}</dd>
1515
</dl>
1616
</div>

index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = function init(options){
3232

3333

3434
webserver.get('/karma', function(req, res, next){
35-
res.sendFile('./index.html');
35+
res.sendFile(__dirname + '/index.html');
3636
});
3737

3838
webserver.get('/karma/:channel', function(req, res, next) {
@@ -84,6 +84,7 @@ module.exports = function init(options){
8484

8585
return {
8686
"^(\\S+)\\+\\+$": function(from, matches) {
87+
if (bot.chans[channel.name].users[matches[1]] === undefined) return channel.say(from + ': no nick matching that was found');
8788
matches[1] = cleanName(matches[1]);
8889
if (from.toLowerCase() == matches[1]) return;
8990
if (cooldown[from]) return channel.say(from + ': you must wait an hour between giving karma');
@@ -92,6 +93,7 @@ module.exports = function init(options){
9293
saveKarma(from, matches[1]);
9394
},
9495
"^(\\S+)\\-\\-$": function(from, matches) {
96+
if (bot.chans[channel.name].users[matches[1]] === undefined) return channel.say(from + ': no nick matching that was found');
9597
matches[1] = cleanName(matches[1]);
9698
if (from.toLowerCase() == matches[1]) return;
9799
if (cooldown[from]) return channel.say(from + ': you must wait an hour between giving karma');
@@ -100,10 +102,11 @@ module.exports = function init(options){
100102
saveKarma(from, matches[1]);
101103
},
102104
"^!karma(?: (\\S+))?$": function(from, matches) {
103-
if (matches[1]) from = matches[1];
104-
from = cleanName(from);
105-
checkKarma(from);
106-
sayKarma(from);
105+
if (matches[1]) nick = matches[1];
106+
nick = cleanName(nick);
107+
if (bot.chans[channel.name].users[nick] === undefined) return channel.say(from + ': no nick matching that was found');
108+
checkKarma(nick);
109+
sayKarma(nick);
107110
}
108111
};
109112
};

0 commit comments

Comments
 (0)