mirror of
				https://github.com/Mikaela/Limnoria.git
				synced 2025-10-31 23:57:22 +01:00 
			
		
		
		
	Seen: Add supybot.plugins.Seen.showLastMessage.
This commit is contained in:
		
							parent
							
								
									1bee83bc2e
								
							
						
					
					
						commit
						243cc0b998
					
				| @ -49,6 +49,10 @@ conf.registerChannelValue(Seen, 'minimumNonWildcard', | ||||
|     registry.NonNegativeInteger(2, _("""The minimum non-wildcard characters | ||||
|     required to perform a 'seen' request. Of course, it only applies if there | ||||
|     is a wildcard in the request."""))) | ||||
| conf.registerChannelValue(Seen, 'showLastMessage', | ||||
|     registry.Boolean(True, _("""Determines whether the last message will | ||||
|     be displayed with @seen. Useful for keeping messages from a channel | ||||
|     private."""))) | ||||
| 
 | ||||
| 
 | ||||
| # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: | ||||
|  | ||||
| @ -202,9 +202,12 @@ class Seen(callbacks.Plugin): | ||||
|             if len(results) == 1: | ||||
|                 (nick, info) = results[0] | ||||
|                 (when, said) = info | ||||
|                 irc.reply(format(_('%s was last seen in %s %s ago: %s'), | ||||
|                 reply = format(_('%s was last seen in %s %s ago'), | ||||
|                                  nick, channel, | ||||
|                                  utils.timeElapsed(time.time()-when), said)) | ||||
|                                  utils.timeElapsed(time.time()-when)) | ||||
|                 if self.registryValue('showLastMessage', channel): | ||||
|                     reply = _('%s: %s') % (reply, said) | ||||
|                 irc.reply(reply) | ||||
|             elif len(results) > 1: | ||||
|                 L = [] | ||||
|                 for (nick, info) in results: | ||||
| @ -266,9 +269,11 @@ class Seen(callbacks.Plugin): | ||||
|             db = self.db | ||||
|         try: | ||||
|             (when, said) = db.seen(channel, '<last>') | ||||
|             irc.reply(format(_('Someone was last seen in %s %s ago: %s'), | ||||
|                              channel, utils.timeElapsed(time.time()-when), | ||||
|                              said)) | ||||
|             reply = format(_('Someone was last seen in %s %s ago'), | ||||
|                              channel, utils.timeElapsed(time.time()-when)) | ||||
|             if self.registryValue('showLastMessage', channel): | ||||
|                 reply = _('%s: %s') % (reply, said) | ||||
|             irc.reply(reply) | ||||
|         except KeyError: | ||||
|             irc.reply(_('I have never seen anyone.')) | ||||
| 
 | ||||
| @ -292,9 +297,12 @@ class Seen(callbacks.Plugin): | ||||
|             db = self.db | ||||
|         try: | ||||
|             (when, said) = db.seen(channel, user.id) | ||||
|             irc.reply(format(_('%s was last seen in %s %s ago: %s'), | ||||
|             reply = format(_('%s was last seen in %s %s ago'), | ||||
|                              user.name, channel, | ||||
|                              utils.timeElapsed(time.time()-when), said)) | ||||
|                              utils.timeElapsed(time.time()-when)) | ||||
|             if self.registryValue('showLastMessage', channel): | ||||
|                 reply = _('%s: %s') % (reply, said) | ||||
|             irc.reply(reply) | ||||
|         except KeyError: | ||||
|             irc.reply(format(_('I have not seen %s.'), user.name)) | ||||
| 
 | ||||
|  | ||||
| @ -59,7 +59,10 @@ class ChannelDBTestCase(ChannelPluginTestCase): | ||||
|         self.irc.feedMsg(ircmsgs.mode(self.channel, args=('+o', self.nick), | ||||
|                                       prefix=self.prefix)) | ||||
|         self.assertRegexp('seen any %s' % self.nick, | ||||
|                           '^%s was last seen' % self.nick) | ||||
|                     '^%s was last seen.*:' % self.nick) | ||||
|         with conf.supybot.plugins.seen.showLastMessage.context(False): | ||||
|             self.assertRegexp('seen any %s' % self.nick, | ||||
|                         '^%s was last seen[^:]*' % self.nick) | ||||
| 
 | ||||
|     def testSeen(self): | ||||
|         self.irc.feedMsg(ircmsgs.join(self.channel, self.irc.nick, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Valentin Lorentz
						Valentin Lorentz