forked from GitHub/dbot
		
	oh jesus [#571]
This commit is contained in:
		
							parent
							
								
									5cdd2d927c
								
							
						
					
					
						commit
						78860ce01a
					
				| @ -22,31 +22,35 @@ var commands = function(dbot) { | ||||
|                 var msTimeout = new Date(new Date().getTime() + (minutes * 60000)); | ||||
|                 dbot.api.timers.addTimeout(msTimeout, function() { | ||||
|                     this.api.unquiet(server, quietee, channel); | ||||
|                     dbot.api.report.notify(server, channel, dbot.t('unquiet_notify', { | ||||
|                         'unquieter': dbot.config.name, | ||||
|                         'channel': channel, | ||||
|                         'quietee': quietee | ||||
|                     })); | ||||
| 
 | ||||
|                     dbot.api.users.resolveUser(server, dbot.config.name, function(user) { | ||||
|                         dbot.api.report.notify('unquiet', server, user, channel, | ||||
|                         dbot.t('unquiet_notify', { | ||||
|                             'unquieter': dbot.config.name, | ||||
|                             'quietee': quietee | ||||
|                         })); | ||||
|                     }); | ||||
|                 }.bind(this));   | ||||
|                 event.reply(dbot.t('tquieted', {  | ||||
|                     'quietee': quietee, | ||||
|                     'minutes': minutes | ||||
|                 })); | ||||
|                 dbot.api.report.notify(server, channel, dbot.t('tquiet_notify', { | ||||
|                     'quieter': quieter, | ||||
|                     'channel': channel, | ||||
|                     'quietee': quietee, | ||||
|                     'minutes': minutes, | ||||
|                     'reason': reason | ||||
|                 })); | ||||
|                 dbot.api.report.notify('quiet', server, event.rUser, channel, | ||||
|                     dbot.t('tquiet_notify', { | ||||
|                         'minutes': minutes, | ||||
|                         'quieter': event.rUser.primaryNick, | ||||
|                         'quietee': quietee, | ||||
|                         'reason': reason | ||||
|                     }) | ||||
|                 ); | ||||
|             } else { | ||||
|                 event.reply(dbot.t('quieted', { 'quietee': quietee })); | ||||
|                 dbot.api.report.notify(server, channel, dbot.t('quiet_notify', { | ||||
|                 dbot.api.report.notify('quiet', server, event.rUser, channel, | ||||
|                 dbot.t('quiet_notify', { | ||||
|                     'quieter': quieter, | ||||
|                     'channel': channel, | ||||
|                     'quietee': quietee, | ||||
|                     'reason': reason | ||||
|                 })); | ||||
|                 }));             | ||||
|             } | ||||
| 
 | ||||
|             this.api.quiet(server, quietee, channel); | ||||
| @ -65,9 +69,9 @@ var commands = function(dbot) { | ||||
| 
 | ||||
|             this.api.unquiet(server, quietee, channel); | ||||
|             event.reply(dbot.t('unquieted', { 'quietee': quietee })); | ||||
|             dbot.api.report.notify(server, channel, dbot.t('unquiet_notify', { | ||||
|             dbot.api.report.notify('unquiet', server, event.rUser, channel, | ||||
|             dbot.t('unquiet_notify', { | ||||
|                 'unquieter': quieter, | ||||
|                 'channel': channel, | ||||
|                 'quietee': quietee | ||||
|             })); | ||||
|         }, | ||||
| @ -81,28 +85,9 @@ var commands = function(dbot) { | ||||
| 
 | ||||
|             this.api.kick(server, kickee, channel, reason + ' (requested by ' + kicker + ')');  | ||||
| 
 | ||||
|             dbot.api.report.notify(server, channel, dbot.t('ckicked', { | ||||
|             dbot.api.report.notify('kick', server, event.rUser, channel, dbot.t('ckicked', { | ||||
|                 'kicker': kicker, | ||||
|                 'kickee': kickee, | ||||
|                 'channel': channel, | ||||
|                 'reason': reason | ||||
|             })); | ||||
|         }, | ||||
| 
 | ||||
|         '~cban': function(event) { | ||||
|             var server = event.server, | ||||
|                 banner = event.user, | ||||
|                 banee = event.input[2], | ||||
|                 channel = event.input[1], | ||||
|                 reason = event.input[3]; | ||||
| 
 | ||||
|             this.api.ban(server, banee, channel); | ||||
|             this.api.kick(server, kickee, channel, reason + ' (requested by ' + banner + ')'); | ||||
| 
 | ||||
|             dbot.api.report.notify(server, channel, dbot.t('cbanned', { | ||||
|                 'banner': banner, | ||||
|                 'banee': banee, | ||||
|                 'channel': channel, | ||||
|                 'reason': reason | ||||
|             })); | ||||
|         }, | ||||
| @ -146,13 +131,6 @@ var commands = function(dbot) { | ||||
|                             'hours': timeout, | ||||
|                             'reason': reason | ||||
|                         }); | ||||
|                         var quoteString = dbot.t('tban_quote', { | ||||
|                             'banee': banee, | ||||
|                             'banner': banner, | ||||
|                             'hours': timeout, | ||||
|                             'time': new Date().toUTCString(), | ||||
|                             'reason': reason | ||||
|                         }); | ||||
|                     } else { | ||||
|                         var notifyString = dbot.t('nbanned', { | ||||
|                             'network': network, | ||||
| @ -160,12 +138,6 @@ var commands = function(dbot) { | ||||
|                             'banee': banee, | ||||
|                             'reason': reason | ||||
|                         }); | ||||
|                         var quoteString = dbot.t('nban_quote', { | ||||
|                             'banee': banee, | ||||
|                             'banner': banner, | ||||
|                             'time': new Date().toUTCString(), | ||||
|                             'reason': reason | ||||
|                         }); | ||||
|                     } | ||||
| 
 | ||||
|                     // Add qutoe category documenting ban
 | ||||
| @ -190,7 +162,7 @@ var commands = function(dbot) { | ||||
|                         adminChannel = event.channel.name; | ||||
|                     } | ||||
| 
 | ||||
|                     dbot.api.report.notify(server, adminChannel, notifyString); | ||||
|                     dbot.api.report.notify('ban', server, event.rUser, adminChannel, notifyString); | ||||
|                     dbot.say(event.server, adminChannel, notifyString); | ||||
| 
 | ||||
|                     if(!_.isUndefined(timeout)) { | ||||
|  | ||||
| @ -20,10 +20,10 @@ | ||||
|         "it": "{quietee} è stato silenziato per {minutes} minuto/i. Ricordati: non essere testardo" | ||||
|     }, | ||||
|     "quiet_notify": { | ||||
|         "en": "Attention: {quieter} has quieted {quietee} in {channel}. The reason given was \"{reason}\"." | ||||
|         "en": "{quieter} has quieted {quietee}. The reason given was \"{reason}\"." | ||||
|     }, | ||||
|     "tquiet_notify": { | ||||
|         "en": "Attention: {quieter} has quieted {quietee} in {channel} for {minutes} minutes. The reason given was \"{reason}\"." | ||||
|         "en": "{quieter} has quieted {quietee} for {minutes} minutes. The reason given was \"{reason}\"." | ||||
|     }, | ||||
|     "unquieted": { | ||||
|         "en": "Unquieted {quietee}. Remember: don't be a coconut.", | ||||
| @ -31,7 +31,7 @@ | ||||
|         "it": "{quietee} può nuovamente parlare. Ricordati: non essere testardo." | ||||
|     }, | ||||
|     "unquiet_notify": { | ||||
|         "en": "Attention: {unquieter} has unquieted {quietee} in {channel}." | ||||
|         "en": "{unquieter} has unquieted {quietee}." | ||||
|     }, | ||||
|     "kicked_dbot": { | ||||
|         "en": "Thou shalt not kick {botname}", | ||||
| @ -44,7 +44,7 @@ | ||||
|         "it": "Non dare pedata a {botname}" | ||||
|     }, | ||||
|     "ckicked": { | ||||
|         "en": "Attention: {kicker} has kicked {kickee} from {channel}. The reason given was: \"{reason}.\"", | ||||
|         "en": "{kicker} has kicked {kickee}. The reason given was: \"{reason}.\"", | ||||
|         "cy": "Sylw: {kicker} wedi cicio'r {kickee} o {channel}. Y rheswm a roddwyd oedd: \"{reason}.\"", | ||||
|         "de": "Achtung: {kicker} hat {kickee} von {channel} verwiesen. Grund: \"{reason}.\"", | ||||
| 	"fr": "Attention : {kicker} a kické {kickee} de {channel}. Raison donnée : \"{reason}.\"", | ||||
|  | ||||
| @ -16,12 +16,53 @@ var report = function(dbot) { | ||||
|                     next(); | ||||
|                 }, 1000); | ||||
|             }); | ||||
|         } | ||||
|         }, | ||||
| 
 | ||||
|         'formatNotify': function(type, server, user, channel, message) { | ||||
|             var notifier = '[' + user.primaryNick + ']'; | ||||
| 
 | ||||
|             if(_.has(this.config.colours, server)) { | ||||
|                 var colours = this.config.colours[server]; | ||||
| 
 | ||||
|                 notifier = '[' + colours['nicks'] + user.primaryNick + '\u000f]'; | ||||
|                 if(_.has(colours.type, type)) { | ||||
|                     type = colours['type'][type] + type + '\u000f'; | ||||
|                 } | ||||
|                 if(_.has(colours['channels'], channel)) { | ||||
|                     channel = colours['channels'][channel] + | ||||
|                         channel + "\u000f"; | ||||
|                 } | ||||
| 
 | ||||
|                 _.each(message.match(/ @([\d\w*|-]+)/g), function(u) { | ||||
|                     u = u.substr(1); | ||||
|                     message = message.replace(u, colours['nicks'] + u + "\u000f"); | ||||
|                     notifier += '[' + colours['nicks'] + u.substr(1) + '\u000f]'; | ||||
|                 }); | ||||
|             } | ||||
| 
 | ||||
|             return dbot.t('notify', { | ||||
|                 'type': type, | ||||
|                 'channel': channel, | ||||
|                 'notifier': notifier, | ||||
|                 'message': message | ||||
|             }); | ||||
|         }.bind(this) | ||||
|     }; | ||||
| 
 | ||||
|     this.api = { | ||||
|         'notify': function(server, channel, message) { | ||||
|             var channel = dbot.instance.connections[server].channels[channel];  | ||||
|         'notify': function(type, server, user, cName, message) { | ||||
|             var id = uuid.v4(); | ||||
|             this.db.save('notifies', id, { | ||||
|                 'id': id, | ||||
|                 'server': server, | ||||
|                 'type': type, | ||||
|                 'channel': channel, | ||||
|                 'user': user.id, | ||||
|                 'time': new Date().getTime(), | ||||
|                 'message': message | ||||
|             }, function() {}); | ||||
| 
 | ||||
|             var channel = dbot.instance.connections[server].channels[cName];  | ||||
|             var ops = _.filter(channel.nicks, function(user) { | ||||
|                 if(this.config.notifyVoice) { | ||||
|                     return user.op || user.voice; | ||||
| @ -30,7 +71,7 @@ var report = function(dbot) { | ||||
|                 } | ||||
|             }, this); | ||||
| 
 | ||||
|             dbot.api.users.resolveChannel(server, channel, function(channel) { | ||||
|             dbot.api.users.resolveChannel(server, cName, function(channel) { | ||||
|                 if(channel) { | ||||
|                     var perOps = channel.op; | ||||
|                     if(this.config.notifyVoice) pOps = _.union(perOps, channel.voice); | ||||
| @ -49,7 +90,9 @@ var report = function(dbot) { | ||||
|                             }); | ||||
|                             this.pNotify[id] = true; | ||||
|                         }.bind(this)); | ||||
| 
 | ||||
|                          | ||||
|                         message = this.internalAPI.formatNotify(type, server, | ||||
|                             user, cName, message); | ||||
|                         this.internalAPI.notify(server, _.pluck(ops, 'name'), message); | ||||
|                     }.bind(this));  | ||||
|                 } | ||||
| @ -93,29 +136,7 @@ var report = function(dbot) { | ||||
|             dbot.api.users.resolveUser(event.server, nick, function(reportee) { | ||||
|                 if(_.has(event.allChannels, channelName)) { | ||||
|                     if(reportee) { | ||||
|                         var notifier = '[' + event.user + ']', | ||||
|                             cChan = channelName, | ||||
|                             type = 'report', | ||||
|                             reporter = event.user; | ||||
|                         if(_.has(this.config.colours, event.server)) { | ||||
|                             var colours = this.config.colours[event.server]; | ||||
| 
 | ||||
|                             reporter = colours['nicks'] + reporter + '\u000f'; | ||||
|                             nick = colours['nicks'] + nick + '\u000f'; | ||||
|                             type = colours['type'][type] + type + '\u000f'; | ||||
|                             if(_.has(colours['channels'], channelName)) { | ||||
|                                 cChan = colours['channels'][channelName] + | ||||
|                                     cChan + "\u000f"; | ||||
|                             } | ||||
|                         } | ||||
| 
 | ||||
|                         this.api.notify(event.server, channelName, dbot.t('report', { | ||||
|                             'type': type, | ||||
|                             'reporter': reporter, | ||||
|                             'reported': nick, | ||||
|                             'channel': cChan, | ||||
|                             'reason': reason | ||||
|                         })); | ||||
|                         this.api.notify('report', event.server, event.rUser, channelName, reason); | ||||
|                         event.reply(dbot.t('reported', { 'reported': nick })); | ||||
|                     } else { | ||||
|                         event.reply(dbot.t('user_not_found', {  | ||||
| @ -130,47 +151,11 @@ var report = function(dbot) { | ||||
|         }, | ||||
| 
 | ||||
|         '~notify': function(event) { | ||||
|             console.log('~notify triggered'); | ||||
|             var channelName = event.input[1], | ||||
|                 message = event.input[2]; | ||||
| 
 | ||||
|             if(_.has(event.allChannels, channelName)) { | ||||
|                 var id = uuid.v4(); | ||||
|                 this.db.save('notifies', id, { | ||||
|                     'id': id, | ||||
|                     'server': event.server, | ||||
|                     'channel': channelName, | ||||
|                     'user': event.rUser.id, | ||||
|                     'time': new Date().getTime(), | ||||
|                     'message': message | ||||
|                 }, function() {}); | ||||
| 
 | ||||
|                 var notifier = '[' + event.user + ']', | ||||
|                     cChan = channelName, | ||||
|                     type = 'notify'; | ||||
|                 if(_.has(this.config.colours, event.server)) { | ||||
|                     var colours = this.config.colours[event.server]; | ||||
| 
 | ||||
|                     notifier = '[' + colours['nicks'] + event.user + '\u000f]'; | ||||
|                     type = colours['type'][type] + type + '\u000f'; | ||||
|                     if(_.has(colours['channels'], channelName)) { | ||||
|                         cChan = colours['channels'][channelName] + | ||||
|                             cChan + "\u000f"; | ||||
|                     } | ||||
| 
 | ||||
|                     _.each(message.match(/ @([\d\w*|-]+)/g), function(user) { | ||||
|                         user = user.substr(1); | ||||
|                         message = message.replace(user, colours['nicks'] + user + "\u000f"); | ||||
|                         notifier += '[' + colours['nicks'] + user.substr(1) + '\u000f]'; | ||||
|                     }); | ||||
|                 } | ||||
|                      | ||||
|                 this.api.notify(event.server, channelName, dbot.t('notify', { | ||||
|                     'type': type, | ||||
|                     'channel': cChan, | ||||
|                     'notifier': notifier, | ||||
|                     'message': message | ||||
|                 })); | ||||
|                 this.api.notify('notify', event.server, event.rUser, channelName, message); | ||||
| 
 | ||||
|                 event.reply(dbot.t('notified', { | ||||
|                     'user': event.user, | ||||
|  | ||||
| @ -12,6 +12,7 @@ block content | ||||
|         tr | ||||
|           th Date | ||||
|           th Channel | ||||
|           th type | ||||
|           th User | ||||
|           th Message  | ||||
|       tbody | ||||
| @ -19,5 +20,6 @@ block content | ||||
|           tr | ||||
|             td #{new Date(notify.time)} | ||||
|             td #{notify.channel} | ||||
|             td #{notify.type} | ||||
|             td #{notify.user} | ||||
|             td #{notify.message} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 reality
						reality