Fixes in the bugtracker plugin, first attempt at not disturbing a meeting

(broken, disabled)
This commit is contained in:
Dennis Kaarsemaker
2007-03-23 20:44:03 +01:00
parent 02f675df11
commit e85c099794
2 changed files with 29 additions and 15 deletions

View File

@ -168,9 +168,9 @@ class Bugtracker(callbacks.PluginRegexp):
component = ''
try:
if component:
bugs[tag][id] = self.get_bug(tracker, id, False)[0].replace('"','(%s) "' % component, 1)
bugs[tag][id] = self.get_bug('',tracker, id, False)[0].replace('"','(%s) "' % component, 1)
else:
bugs[tag][id] = self.get_bug(tracker, id, False)[0]
bugs[tag][id] = self.get_bug('',tracker, id, False)[0]
except:
self.log.info("Unable to get new bug %d" % id)
pass
@ -278,7 +278,7 @@ class Bugtracker(callbacks.PluginRegexp):
list = wrap(list, [additional('text')])
def bugSnarfer(self, irc, msg, match):
r"""\b(?P<bt>(([a-z0-9]+)?\s+bugs?|[a-z]+))\s+#?(?P<bug>\d+(?!\d*\.\d+)((,|\s*(and|en|et|und|ir))\s*#?\d+(?!\d*\.\d+))*)"""
r"""\b(?P<bt>(([a-z0-9]+)?\s+bugs?|[a-z0-9]+))\s+#?(?P<bug>\d+(?!\d*\.\d+)((,|\s*(and|en|et|und|ir))\s*#?\d+(?!\d*\.\d+))*)"""
if msg.args[0][0] == '#' and not self.registryValue('bugSnarfer', msg.args[0]):
return
nbugs = msg.tagged('nbugs')
@ -294,10 +294,13 @@ class Bugtracker(callbacks.PluginRegexp):
# Get tracker name
bugids = match.group('bug')
print bugids
reps = ((' ',''),('#',''),('and',','),('en',','),('et',','),('und',','),('ir',','))
for r in reps:
bugids = bugids.replace(r[0],r[1])
bugids = bugids.split(',')[:5-nbugs]
if not sure_bug:
bugids = [x for x in bugids if int(x) > 100]
msg.tag('nbugs', nbugs + len(bugids))
bt = map(lambda x: x.lower(), match.group('bt').split())
name = ''
@ -331,10 +334,8 @@ class Bugtracker(callbacks.PluginRegexp):
else:
for bugid in bugids:
bugid = int(bugid)
if not self.is_ok(msg.args[0],tracker, bugid):
continue
try:
report = self.get_bug(tracker,bugid,self.registryValue('showassignee', msg.args[0]))
report = self.get_bug(msg.args[0],tracker,bugid,self.registryValue('showassignee', msg.args[0]))
except BugNotFoundError:
if self.registryValue('replyWhenNotFound'):
irc.error("%s bug %d could not be found" % (tracker.description, bugid))
@ -362,9 +363,7 @@ class Bugtracker(callbacks.PluginRegexp):
tracker = self.get_tracker(match.group(0),match.group('sfurl'))
if not tracker:
return
if not self.is_ok(msg.args[0],tracker, int(match.group('bug'))):
return
report = self.get_bug(tracker,int(match.group('bug')),self.registryValue('showassignee', msg.args[0]), do_url = False)
report = self.get_bug(msg.args[0],tracker,int(match.group('bug')),self.registryValue('showassignee', msg.args[0]), do_url = False)
except BugtrackerError, e:
irc.error(str(e))
else:
@ -405,9 +404,11 @@ class Bugtracker(callbacks.PluginRegexp):
return tracker
return None
def get_bug(self, tracker, id, do_assignee, do_url = True):
def get_bug(self, channel, tracker, id, do_assignee, do_url = True):
reports = []
for r in tracker.get_bug(id):
if not self.is_ok(channel, tracker, r[0]):
continue
(bid, product, title, severity, status, assignee, url) = r
severity = severity[0].upper() + severity[1:].lower()
status = status[0].upper() + status[1:].lower()

View File

@ -108,23 +108,29 @@ class Webcal(callbacks.Plugin):
newtopic = template % str(newtopic)
return preamble + newtopic
def _meeting_in_progress(self, url):
def _meeting_in_progress(self, url, channel):
return False
if url not in self.cache.keys():
self._refresh_cache(url)
now = datetime.datetime.now(pytz.UTC)
events = filter(lambda x: self._filter(x,channel,now),self.cache[url])[:1]
if len(events):
if len(events) > 1 and events[1].startDate < now:
if len(events) and events[0].endDate < now:
events = events[1:]
if not events:
return False
ev0 = events[0]
print now, ev0.startDate, ev0.endDate
delta = abs(ev0.startDate - now)
if ev0.startDate < now or (delta.days == 0 and delta.seconds < 10 * 60):
if ev0.startDate < now and delta.seconds > 10 * 5:
return True
return False
def _autotopics(self):
for c in self.irc.state.channels:
url = self.registryValue('url', c)
if self._meeting_in_progress(url, c):
continue
if url and self.registryValue('doTopic', c):
newtopic = self._gettopic(url, c)
if newtopic and not (newtopic.strip() == self.irc.state.getTopic(c).strip()):
@ -145,9 +151,12 @@ class Webcal(callbacks.Plugin):
def topic(self, irc, msg, args):
url = self.registryValue('url', msg.args[0])
if not url or not self.registryValue('doTopic'):
if not url or not self.registryValue('doTopic',channel=msg.args[0]):
return
self._refresh_cache(url)
if self._meeting_in_progress(url, msg.args[0]):
irc.error("Can't update topic while a meeting is in progress")
return
newtopic = self._gettopic(url, msg.args[0])
# Only change topic if it actually is different!
if not (newtopic.strip() == irc.state.getTopic(msg.args[0]).strip()):
@ -191,7 +200,11 @@ class Webcal(callbacks.Plugin):
if not tzs or 'gmt' in tz.lower():
irc.error('Unknown timezone: %s - Full list: http://bugbot.ubuntulinux.nl/timezones.html' % tz)
else:
irc.reply('Schedule for %s: %s' % (tzs[0],self._gettopic(url, c, timezone=tzs[0], no_topic=True)))
if self._meeting_in_progress(url, c):
irc.error('Please don\'t use @schedule during a meeting')
irc.reply('Schedule for %s: %s' % (tzs[0],self._gettopic(url, c, timezone=tzs[0], no_topic=True)), private=True)
else:
irc.reply('Schedule for %s: %s' % (tzs[0],self._gettopic(url, c, timezone=tzs[0], no_topic=True)))
schedule = wrap(schedule, [additional('text')])
def now(self, irc, msg, args, tz):