107
112
return _('Launchpad bug #%d in %s: "%s" (%s, %s).') % \
108
113
(bugnumber, data.task, data.title, data.status, data.importance)
115
def _is_duplicated(self, channel, bugnumber):
116
if not channel in self._lastbugs:
117
self._lastbugs[channel] = {}
118
lim = time.time() - 120 # only repeat bug information every two minutes
119
# the main reason for this is to avoid madness
120
# when two bots are in the channel
121
if bugnumber not in self._lastbugs[channel] or \
122
self._lastbugs[channel][bugnumber] < lim:
123
self._lastbugs[channel][bugnumber] = time.time()
110
127
def _bug_info(self, bot, string, channel):
111
128
"""Parses a line looking for bug numbers, and sends information about
113
130
for bugnumber in set(self.bugrule.findall(string)):
131
direct_request = string.lower().startswith(bot.nickname.lower()) \
132
and string[len(bot.nickname):][0] in (' ', ',', ':')
133
if self._is_duplicated(channel, bugnumber) and not direct_request:
114
135
bug = self._get_bug_info(int(bugnumber), bot, channel)
116
137
bot.msg(channel, bug + ' https://launchpad.net/bugs/%d' % \
122
143
for bugnumber in set(self.bugurlrule.findall(data)):
123
144
if not 'bugs' in data:
146
if self._is_duplicated(channel, bugnumber):
125
148
bug = self._get_bug_info(int(bugnumber), bot, channel)
127
150
bot.msg(channel, bug)