/usr/lib/python2.7/dist-packages/gplugs/bugtracker.py is in gozerbot 0.99.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | # -*- coding: utf-8 -*-
# Support for bugtrackers
# Wijnand 'tehmaze' Modderman - http://tehmaze.com
# BSD License
#
# ======
# TODO
# ======
# * add authorization support to bugtrackers
# * add write support to bugtrackers (close/open bug)
#
# ======
# BUGS
# ======
# * I did test these bugtrackers on various installations, although not everything
# will work on all installations, for example on older versions or on bugtrackers
# that restyled the complete layout
from gozerbot.aliases import aliases
from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.datadir import datadir
from gozerbot.examples import examples
from gozerbot.generic import geturl, geturl2, striphtml, useragent
from gozerbot.persist.pdod import Pdod
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.users import users
from gozerbot.utils.generic import convertpickle
import copy
import os
import re
import urllib, urllib2
import xml.dom.minidom
plughelp.add('bugtracker', 'various bug tracker support, define a bugtracker for the channel with bugtracker-set')
cfg = PersistConfig()
cfg.define('sep', '..')
class BugTrackerNotFound(Exception):
pass
class BugTrackerNotImplemented(Exception):
pass
class BugTrackerNotSupported(Exception):
pass
class BugTracker:
bugurls = [] # regexp patterns that could match a bugtracker url
bugtags = re.compile('(?:bug|ticket)\s?#(\d+)', re.I)
def __init__(self, baseUrl, autoshow):
self.url = baseUrl.rstrip('/')
self.autoshow = autoshow
def close(self, bugId, userhost='', message='', action=''):
raise BugTrackerNotImplemented
def close_url(self, bugId):
raise BugTrackerNotImplemented
def comments(self, bugId):
raise BugTrackerNotImplemented
def comments_url(self, bugId):
raise BugTrackerNotImplemented
def list(self):
raise BugTrackerNotImplemented
def list_url(self):
raise BugTrackerNotImplemented
def open(self, message=''):
raise BugTrackerNotImplemented
def open_url(self):
raise BugTrackerNotImplemented
def show(self, bugId):
raise BugTrackerNotImplemented
def show_url(self, bugId):
raise BugTrackerNotImplemented
def handle_close(self, bot, ievent):
if len(ievent.args) < 3:
ievent.missing('<bug id> <action> <message>')
return
try:
status = self.close(ievent.args[0], users.getname(ievent.userhost),
' '.join(ievent.args[2:]), ievent.args[1])
ievent.reply('ok')
except AssertionError, e:
ievent.reply('error: %s' % e)
except BugTrackerNotImplemented:
ievent.reply('error: not implemented in this bug tracker')
except BugTrackerNotSupported, e:
ievent.reply('error: not supported: %s' % e)
except BugTrackerNotFound, e:
ievent.reply('error: not found: %s' % e)
def handle_comments(self, bot, ievent):
if not ievent.args or not ievent.args[0].isdigit():
ievent.missing('<bug id>')
return
try:
comments = self.comments(ievent.args[0])
if comments:
ievent.reply('comments: ', comments, dot=' %s ' % cfg.get('sep'), nr=True, nritems=True)
else:
ievent.reply('no comments found')
except AssertionError, e:
ievent.reply('error: %s' % e)
except BugTrackerNotImplemented:
ievent.reply('error: not implemented in this bug tracker')
except BugTrackerNotSupported, e:
ievent.reply('error: not supported: %s' % e)
except BugTrackerNotFound, e:
ievent.reply('error: not found: %s' % e)
def handle_list(self, bot, ievent):
try:
bugs = self.list()
if bugs:
ievent.reply('open bugs: ', bugs, dot=' %s ' % cfg.get('sep'))
else:
ievent.reply('no open bugs found!')
except BugTrackerNotImplemented:
ievent.reply('error: not implemented in this bug tracker')
except BugTrackerNotSupported, e:
ievent.reply('error: not supported: %s' % e)
except BugTrackerNotFound, e:
ievent.reply('error: not found: %s' % e)
def handle_show(self, bot, ievent):
if len(ievent.args) != 1:
try:
open_url = self.open_url()
ievent.missing('<bug id> -- if you were looking to report a bug, please go to %s' % open_url)
except BugTrackerNotImplemented:
ievent.missing('<bug id>')
return
try:
status = self.show(ievent.args[0])
result = []
keys = status.keys() ; keys.sort()
for key in keys:
if status[key]:
result.append('%s=%s' % (key, status[key]))
result.append(self.show_url(ievent.args[0]))
ievent.reply(result, dot=' %s ' % cfg.get('sep'))
except AssertionError, e:
ievent.reply('error: %s' % e)
except BugTrackerNotImplemented:
ievent.reply('error: not implemented in this bug tracker')
except BugTrackerNotSupported, e:
ievent.reply('error: not supported: %s' % e)
except BugTrackerNotFound, e:
ievent.reply('error: not found: %s' % e)
def scan_privmsg(self, bot, ievent):
if not self.autoshow:
return
if not self.bugurls:
return
for bugurl in self.bugurls:
test = bugurl.findall(ievent.origtxt)
if test:
nevent = copy.copy(ievent)
nevent.args = [test[0]]
self.handle_show(bot, nevent)
del nevent
return
test = self.bugtags.findall(ievent.origtxt)
if test:
nevent = copy.copy(ievent)
nevent.args = [test[0]]
self.handle_show(bot, nevent)
del nevent
return
class Bugzilla(BugTracker):
def __init__(self, url, autoshow):
BugTracker.__init__(self, url, autoshow)
self.bugurls = [
re.compile(r'%s/show_bug.*id=(\d+)' % self.url)
]
def list(self):
csv = geturl2(self.list_url_summary())
num = 0
for line in csv.splitlines():
try:
num += int(line.split(',')[1])
except ValueError:
pass
bugs = []
if num > 100:
bugs.append('showing 100-%d' % num)
csv = geturl2(self.list_url())
for line in csv.splitlines()[1:]:
part = line.split(',')
bugs.append('%s (%s)' % (part[0], part[1].replace('"', '')))
if len(bugs) > 100:
break
return bugs
def list_url(self):
return '%s/buglist.cgi?=&action=wrap&bug_file_loc=&bug_file_loc_type=allwordssubstr&bug_id=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bugidtype=include&chfieldfrom=&chfieldto=Now&chfieldvalue=&email1=&email2=&emailtype1=substring&emailtype2=substring&field-1-0-0=bug_status&field0-0-0=noop&keywords=&keywords_type=allwords&long_desc=&long_desc_type=substring&query_format=advanced&remaction=&short_desc=&short_desc_type=allwordssubstr&status_whiteboard=&status_whiteboard_type=allwordssubstr&type-1-0-0=anyexact&type0-0-0=noop&value-1-0-0=NEW%%2CASSIGNED%%2CREOPENED&value0-0-0=&ctype=csv' % self.url
def list_url_summary(self):
return '%s/report.cgi?bug_file_loc=&bug_file_loc_type=allwordssubstr&bug_id=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bugidtype=include&chfieldfrom=&chfieldto=Now&chfieldvalue=&email1=&email2=&emailtype1=substring&emailtype2=substring&field0-0-0=noop&keywords=&keywords_type=allwords&long_desc=&long_desc_type=substring&short_desc=&short_desc_type=allwordssubstr&status_whiteboard=&status_whiteboard_type=allwordssubstr&type0-0-0=noop&value0-0-0=&x_axis_field=&y_axis_field=bug_status&z_axis_field=&width=600&height=350&action=wrap&ctype=csv&format=table' % self.url
def show(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
bugxml = geturl(self.show_url_xml(bugId))
bugdom = xml.dom.minidom.parseString(bugxml)
try:
bugset = bugdom.getElementsByTagName('bug')[0]
except:
raise BugTrackerNotFound('could not find bug tag')
bugget = {'creation_ts': 'created', 'product': 'product', 'component': 'component',
'version': 'version', 'bug_status': 'status', 'resolution': 'resolution',
'priority': 'priority', 'bug_severity': 'severity', 'reporter': 'reporter',
'short_desc': 'description', 'assigned_to': 'assigned to'}
data = {}
for tag in bugget.keys():
try:
value = bugset.getElementsByTagName(tag)[0].firstChild.nodeValue
data[bugget[tag]] = value
except:
pass
return data
def show_url(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
return '%s/show_bug.cgi?id=%s' % (self.url, bugId)
def show_url_xml(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
return '%s/show_bug.cgi?ctype=xml&id=%s' % (self.url, bugId)
class Flyspray(BugTracker):
def __init__(self, url, autoshow):
BugTracker.__init__(self, url, autoshow)
self.bugurls = [
re.compile(r'%s/task/(\d+)' % self.url)
]
def list(self):
bugrss = geturl(self.list_url())
bugdom = xml.dom.minidom.parseString(bugrss)
bugall = bugdom.getElementsByTagName('entry')
bugs = []
if bugall:
for entry in bugall:
try:
bugid = entry.getElementsByTagName('id')[0].firstChild.nodeValue.split(':')[2]
bugs.append(bugid)
except:
pass
return bugs
def list_url(self):
return '%s/feed.php?feed_type=atom&project=' % self.url
def show(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
html = geturl2(self.show_url(bugId))
data = {}
stat = ''
for line in html.splitlines():
line = line.strip()
if not line:
continue
elif '<td headers="category">' in line:
stat = 'category'
elif '<td headers="status">' in line:
stat = 'status'
elif '<td headers="assignedto">' in line:
stat = 'assigned to'
elif '<td headers="os">' in line:
data['os'] = striphtml(line).strip()
elif '<td headers="severity">' in line:
data['severity'] = striphtml(line).strip()
elif '<td headers="priority">' in line:
data['priority'] = striphtml(line).strip()
elif '<td headers="reportedver">' in line:
data['version'] = striphtml(line).strip()
elif '<h2 class="summary' in line:
stat = 'summary'
elif '<a href="#comments">Comments (' in line:
data['comments'] = line.split('(', 1)[1].split(')')[0]
# stats
elif stat:
if stat in ['category', 'status', 'assigned to', 'summary']:
data[stat] = striphtml(line).strip()
stat = ''
return data
def show_url(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
return '%s/task/%s' % (self.url, bugId)
class GoogleCode(BugTracker):
def __init__(self, url, autoshow):
BugTracker.__init__(self, url, autoshow)
self.bugurls = [
re.compile(r'%s/issues.*id=(\d+)' % self.url)
]
def close(self, *args):
raise BugTrackerNotSupported("google code needs authorization which I don't support")
def list(self):
html = geturl2(self.list_url())
bugs = []
for line in html.splitlines():
if '<a href="detail?id' in line and '&' in line:
bug = line.split('id=')[1].split('&')[0]
if not bug in bugs:
bugs.append(bug)
return bugs
def list_url(self):
return '%s/issues/list' % self.url
def open(self, *args):
raise BugTrackerNotSupported("google code needs authorization which I don't support")
def show(self, bugId):
assert bugId.isdigit(), "bug id has to ba a number"
html = geturl2(self.show_url(bugId)).splitlines()
data = {}
stat = ''
for line in html:
line = line.strip()
if not line:
continue
if line.startswith('<span class=h3 >'):
data['summary'] = striphtml(line)
elif line.startswith('<tr><th align=left>Status:'):
stat = 'status'
elif line.startswith('class=label><b>Type-</b>'):
data['type'] = striphtml(line.split('</b>')[1])
elif line.startswith('class=label><b>Priority-</b>'):
data['priority'] = striphtml(line.split('</b>')[1])
elif line.startswith('<span class=author>') and not data.has_key('author'):
stat = 'author'
elif line.startswith('<tr><th align=left>Owner:'):
stat = 'owner'
elif line.startswith('<span class="date" title="'):
data['date'] = striphtml(line)
elif striphtml(line) == '':
pass
# stats
elif stat == 'author':
data['reporter'] = striphtml(line)
stat = ''
elif stat == 'owner':
data['owner'] = striphtml(line)
stat = ''
elif stat == 'status':
data['status'] = striphtml(line)
stat = ''
return data
def show_url(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
return '%s/issues/detail?id=%s' % (self.url.rstrip('/'), bugId)
class Mantis(BugTracker):
def __init__(self, url, autoshow):
BugTracker.__init__(self, url, autoshow)
def show(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
html = geturl2(self.show_url(bugId))
if 'APPLICATION ERROR #1100' in html:
raise BugTrackerNotFound('issue not found')
data = {'notes': 0}
stat = ''
skip = 0
for line in html.splitlines():
line = line.strip().replace('\t', '')
if skip > 0:
skip -= 1
continue
elif not line:
continue
elif '<!-- Category -->' in line:
skip = 1
stat = 'category'
elif '<!-- Severity -->' in line:
skip = 1
stat = 'severity'
elif '<!-- Reproducibility -->' in line:
skip = 1
stat = 'reproducibility'
elif '<!-- Reporter -->' in line:
skip = 3
stat = 'reporter'
elif '<!-- Priority -->' in line:
skip = 1
stat = 'priority'
elif '<!-- Resolution -->' in line:
skip = 1
stat = 'resolution'
elif '<!-- Status -->' in line:
skip = 3
stat = 'status'
elif '<!-- Summary -->' in line:
skip = 4
stat = 'summary'
elif '<td class="bugnote-public">' in line:
data['notes'] += 1
# stats
elif stat:
if stat in ['category', 'severity', 'reproducibility', 'reporter',
'priority', 'resolution', 'status', 'summary']:
data[stat] = striphtml(line)
stat = ''
return data
def show_url(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
return '%s/view.php?id=%s' % (self.url.rstrip('/'), bugId)
class Trac(BugTracker):
def __init__(self, url, autoshow):
BugTracker.__init__(self, url, autoshow)
self.bugurls = [
re.compile(r'%s/ticket/(\d+)' % self.url)
]
def comments(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
bugrss = geturl(self.comments_url(bugId))
bugdom = xml.dom.minidom.parseString(bugrss)
bugall = bugdom.getElementsByTagName('item')
comments = []
if bugall:
for item in bugall:
title = item.getElementsByTagName('title')[0].firstChild.nodeValue
if 'comment added' in title:
try:
author = item.getElementsByTagName('dc:creator')[0].firstChild.nodeValue
except IndexError:
author = 'anonymous'
comment = item.getElementsByTagName('description')[0].firstChild.nodeValue
comment = striphtml(comment.replace('\n', ' ')).strip()
while ' ' in comment:
comment = comment.replace(' ', ' ')
comments.append('%s: %s' % (author, comment))
return comments
def comments_url(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
return '%s/ticket/%s?format=rss' % (self.url, bugId)
def list(self):
tsv = geturl2(self.list_url()).splitlines()
bugs = []
keys = map(lambda x: x.strip(), tsv[0].split())
for item in tsv[1:]:
data = {}
part = item.split('\t')
# dirty hack to allow unescaped multilines in trac
if part[0].isdigit() and part[1].isdigit() and len(part) == len(keys):
data = dict(zip(keys, part))
bugs.append('%s (%s)' % (data['summary'], data['ticket']))
return bugs
def list_url(self):
return '%s/report/1?format=tab&USER=anonymous' % self.url
def show(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
tsv = geturl2(self.show_url(bugId)+'?format=tab').splitlines()
keys = map(lambda x: x.strip(), tsv[0].split())
part = tsv[1].split('\t')
data = dict(zip(keys, part))
return data
def show_url(self, bugId):
assert bugId.isdigit(), "bug id has to be a number"
return '%s/ticket/%s' % (self.url, bugId)
def open(self, reporter, message, type='defect', priority='minor'):
postdata = {
'reporter': reporter,
'summary': message,
'type': type,
'description': message,
'priority': priority,
'milestone': '',
'component': '',
'version': '',
'keywords': '',
'owner': '',
'cc': '',
# hidden stuff
'action': 'create',
'status': 'new',
}
def open_url(self):
return '%s/newticket' % self.url
def close(self, bugId, reporter, message, action='fixed'):
actions = ['fixed', 'invalid', 'wontfix', 'duplicate', 'worksforme']
# input check
assert bugId.isdigit(), "bug id has to be a number"
assert action in actions, "action has to be one of: %s" % ', '.join(actions)
showdata = self.show(bugId)
postdata = {
'reporter': reporter,
'comment': message,
'action': 'resolve',
'type': 'defect',
'resolve_resolution': action,
'summary': showdata['summary'],
'priority': showdata['priority'],
'milestone': showdata['milestone'],
'component': showdata['component'],
'version': showdata['version'],
'keywords': showdata['keywords'],
'cc': '',
}
postdata = urllib.urlencode(postdata)
req = urllib2.Request('%s/ticket/%s' % (self.url, bugId), data=postdata)
req.add_header('User-agent', useragent())
return urllib2.urlopen(req).read()
class BugManager(Pdod):
types = {
'bugzilla': Bugzilla,
'flyspray': Flyspray,
'googlecode': GoogleCode,
'mantis': Mantis,
'trac': Trac
}
instances = {
}
def __init__(self):
Pdod.__init__(self, os.path.join(datadir + os.sep + 'plugs' + os.sep \
+ 'bugtracker', 'bugtracker'))
self.load()
def add(self, bot, ievent, type, url):
assert type in self.types.keys(), "unknown bugtracker type, supported: %s" % ', '.join(self.types.keys())
if hasattr(bot, 'name'):
botname = bot.name
else:
botname = bot
if hasattr(ievent, 'channel'):
channel = ievent.channel
else:
channel = ievent
if not self.data.has_key(botname):
self.data[botname] = {}
self.data[bot.name][channel] = [url, type, False]
self.save()
self.start(bot, ievent)
def check(self, bot, ievent):
if not self.instances.has_key(bot.name):
return False
if not self.instances[bot.name].has_key(ievent.channel):
return False
return True
def load(self):
for bot in self.data.keys():
for channel in self.data[bot].keys():
self.start(bot, channel)
def start(self, bot, ievent):
if hasattr(bot, 'name'):
botname = bot.name
else:
botname = bot
if hasattr(ievent, 'channel'):
channel = ievent.channel
else:
channel = ievent
if not self.instances.has_key(botname):
self.instances[botname] = {}
data = self.data[botname][channel]
if not len(data) == 3:
data.append(False)
self.data[botname][channel] = data
self.save()
self.instances[botname][channel] = self.types[data[1]](data[0], data[2])
# "internals"
def handle_tracker_info(self, bot, ievent):
if not self.check(bot, ievent):
ievent.reply('no bugtracker active on %s' % ievent.channel)
else:
data = self.data[bot.name][ievent.channel]
ievent.reply('bugtracker type: %s .. url: %s .. autoshow: %s' % (data[1], data[0], str(data[2])))
def handle_tracker_set(self, bot, ievent):
if len(ievent.args) != 2:
ievent.missing('<type> <url>')
return
try:
self.add(bot, ievent, ievent.args[0], ievent.args[1])
ievent.reply('ok')
except AssertionError, e:
ievent.reply('error: %s' % e)
def handle_autoshow(self, bot, ievent):
if not self.check(bot, ievent):
ievent.reply('no bugtracker configured')
return
self.data[bot.name][ievent.channel][2] = not self.data[bot.name][ievent.channel][2]
try:
self.instances[bot.name][ievent.channel].autoshow = self.data[bot.name][ievent.channel][2]
except:
pass
self.save()
ievent.reply('autoshow is now %s' % str(self.data[bot.name][ievent.channel][2]))
# proxies
def handle_close(self, bot, ievent):
if not self.check(bot, ievent):
ievent.reply('no bugtracker configured')
return
try:
self.instances[bot.name][ievent.channel].handle_close(bot, ievent)
except Exception, e:
ievent.reply('failed to get bug information: %s' % str(e))
def handle_comments(self, bot, ievent):
if not self.check(bot, ievent):
ievent.reply('no bugtracker configured')
return
#try:
self.instances[bot.name][ievent.channel].handle_comments(bot, ievent)
#except Exception, e:
# ievent.reply('failed to get bug information: %s' % str(e))
def handle_list(self, bot, ievent):
if not self.check(bot, ievent):
ievent.reply('no bugtracker configured')
return
self.instances[bot.name][ievent.channel].handle_list(bot, ievent)
return
try:
self.instances[bot.name][ievent.channel].handle_list(bot, ievent)
except Exception, e:
ievent.reply('failed to get bug information: %s' % str(e))
def handle_open(self, bot, ievent):
if not self.check(bot, ievent):
ievent.reply('no bugtracker configured')
return
try:
self.instances[bot.name][ievent.channel].handle_open(bot, ievent)
except Exception, e:
ievent.reply('failed to get bug information: %s' % str(e))
def handle_show(self, bot, ievent):
if not self.data.has_key(bot.name):
ievent.reply('no bugtracker configured')
return False
try:
self.instances[bot.name][ievent.channel].handle_show(bot, ievent)
except Exception, e:
ievent.reply('failed to fetch bug information: %s' % str(e))
def cb_privmsg(self, bot, ievent):
if not self.instances.has_key(bot.name):
return 0
if not self.instances[bot.name].has_key(ievent.channel):
return 0
self.instances[bot.name][ievent.channel].scan_privmsg(bot, ievent)
bugtrackers = BugManager()
def init():
callbacks.add('PRIVMSG', bugtrackers.cb_privmsg)
def upgrade():
convertpickle(datadir + os.sep + 'old' + os.sep + 'bugtracker', \
datadir + os.sep + 'plugs' + os.sep + 'bugtracker' + os.sep + 'bugtracker')
cmnds.add('bug-autoshow', bugtrackers.handle_autoshow, ['OPER'])
examples.add('bug-autoshow', 'toggle automatic retrieval of bug information', 'bug-autoshow')
cmnds.add('bug-close', bugtrackers.handle_close, ['OPER', 'BUGS'])
examples.add('bug-close', 'close a bug', 'bug-close 42 fixed Typo on line 23')
cmnds.add('bug-comments', bugtrackers.handle_comments, ['USER'])
examples.add('bug-comments', 'show all comments on a bug', 'bug-comments 42')
cmnds.add('bug-list', bugtrackers.handle_list, ['USER', 'BUGS'])
examples.add('bug-list', 'list all open bugs', 'bug-list')
cmnds.add('bug-show', bugtrackers.handle_show, ['USER'])
examples.add('bug-show', 'show a bug', 'bug-show 42')
cmnds.add('bugtracker-info', bugtrackers.handle_tracker_info, ['BUGSOPER', 'OPER'])
cmnds.add('bugtracker-set', bugtrackers.handle_tracker_set, ['BUGSOPER', 'OPER'])
examples.add('bugtracker-set', 'set a bugtracker for the channel', 'bugtracker-set gozerbot http://dev.gozerbot.org')
aliases.data['bug'] = 'bug-show'
|