# Path: cardinal/decorators.py
# def command(triggers):
#     if isinstance(triggers, str):
#         triggers = [triggers]
# 
#     if not isinstance(triggers, list):
#         raise TypeError("Command must be a trigger string or list of triggers")
# 
#     def wrap(f):
#         f.commands = triggers
#         return f
# 
#     return wrap
# 
# def event(triggers):
#     if isinstance(triggers, str):
#         triggers = [triggers]
# 
#     if not isinstance(triggers, list):
#         raise TypeError("Event must be a trigger string or list of triggers")
# 
#     def wrap(f):
#         f.events = triggers
#         return f
# 
#     return wrap
# 
# def help(lines):
#     # For backwards compatibility
#     if isinstance(lines, str):
#         lines = [lines]
# 
#     if not isinstance(lines, list):
#         raise TypeError("Help must be a help string or list of help strings")
# 
#     def wrap(f):
#         # Create help list or prepend to it
#         if not hasattr(f, 'help'):
#             f.help = lines
#         else:
#             f.help = lines + f.help
# 
#         return f
# 
#     return wrap
# 
# Path: cardinal/exceptions.py
# class EventRejectedMessage(CardinalException):
#     """Raised when an event callback wants to reject an event."""


import re
import logging
import requests
from cardinal.decorators import command, event, help
from cardinal.exceptions import EventRejectedMessage
from twisted.internet import defer
from twisted.internet.threads import deferToThread
                                 "...and %d more" %
                                 (res['total_count'] - self.max_show_issues))
            elif res['total_count'] == 0:
                cardinal.sendMsg(channel,
                                 "No matching issues found in %s" % repo)
        except requests.exceptions.HTTPError:
            cardinal.sendMsg(channel,
                             "Couldn't find %s#%d" % (repo, int(query)))

    @event('urls.detection')
    @defer.inlineCallbacks
    def get_repo_info(self, cardinal, channel, url):
        match = re.match(ISSUE_URL_REGEX, url)
        if not match:
            match = re.match(REPO_URL_REGEX, url)
        if not match:
            raise EventRejectedMessage

        groups = match.groups()
        try:
            if len(groups) == 3:
                yield self._show_issue(cardinal,
                                       channel,
                                       '%s/%s' % (groups[0], groups[1]),
                                       int(groups[2]))
            elif len(groups) == 2:
                yield self._show_repo(cardinal,
                                      channel,
                                      '%s/%s' % (groups[0], groups[1]))
        except requests.exceptions.HTTPError:

# Path: cardinal/decorators.py
# def command(triggers):
#     if isinstance(triggers, str):
#         triggers = [triggers]
# 
#     if not isinstance(triggers, list):
#         raise TypeError("Command must be a trigger string or list of triggers")
# 
#     def wrap(f):
#         f.commands = triggers
#         return f
# 
#     return wrap
# 
# def event(triggers):
#     if isinstance(triggers, str):
#         triggers = [triggers]
# 
#     if not isinstance(triggers, list):
#         raise TypeError("Event must be a trigger string or list of triggers")
# 
#     def wrap(f):
#         f.events = triggers
#         return f
# 
#     return wrap
# 
# def help(lines):
#     # For backwards compatibility
#     if isinstance(lines, str):
#         lines = [lines]
# 
#     if not isinstance(lines, list):
#         raise TypeError("Help must be a help string or list of help strings")
# 
#     def wrap(f):
#         # Create help list or prepend to it
#         if not hasattr(f, 'help'):
#             f.help = lines
#         else:
#             f.help = lines + f.help
# 
#         return f
# 
#     return wrap
# 
# Path: cardinal/exceptions.py
# class EventRejectedMessage(CardinalException):
#     """Raised when an event callback wants to reject an event."""


# Path: plugins/github/plugin.py
import re
import logging
import requests
from cardinal.decorators import command, event, help
from cardinal.exceptions import EventRejectedMessage
from twisted.internet import defer
from twisted.internet.threads import deferToThread

                                 "...and %d more" %
                                 (res['total_count'] - self.max_show_issues))
            elif res['total_count'] == 0:
                cardinal.sendMsg(channel,
                                 "No matching issues found in %s" % repo)
        except requests.exceptions.HTTPError:
            cardinal.sendMsg(channel,
                             "Couldn't find %s#%d" % (repo, int(query)))

    @event('urls.detection')
    @defer.inlineCallbacks
    def get_repo_info(self, cardinal, channel, url):
        match = re.match(ISSUE_URL_REGEX, url)
        if not match:
            match = re.match(REPO_URL_REGEX, url)
        if not match:
            raise EventRejectedMessage

        groups = match.groups()
        try:
            if len(groups) == 3:
                yield self._show_issue(cardinal,
                                       channel,
                                       '%s/%s' % (groups[0], groups[1]),
                                       int(groups[2]))
            elif len(groups) == 2:
                yield self._show_repo(cardinal,
                                      channel,
                                      '%s/%s' % (groups[0], groups[1]))
        except requests.exceptions.HTTPError:

            raise EventRejectedMessage