# Path: cardinal/decorators.py
# 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
# 
# Path: cardinal/exceptions.py
# class EventRejectedMessage(CardinalException):
#     """Raised when an event callback wants to reject an event."""


import re
import requests
import twitter
from urllib.parse import urlparse
from twisted.internet import defer
from twisted.internet.threads import deferToThread
from cardinal.decorators import event
from cardinal.exceptions import EventRejectedMessage




class TwitterPlugin:
    def __init__(self, config):
        consumer_key = config['consumer_key']
        consumer_secret = config['consumer_secret']

        if not all([consumer_key, consumer_secret]):
            raise Exception(
                "Twitter plugin requires consumer_key and consumer_secret"
            )

        self.api = twitter.Api(
            consumer_key=consumer_key,
            consumer_secret=consumer_secret,
            application_only_auth=True,
        )

    @defer.inlineCallbacks

# Path: cardinal/decorators.py
# 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
# 
# Path: cardinal/exceptions.py
# class EventRejectedMessage(CardinalException):
#     """Raised when an event callback wants to reject an event."""


# Path: plugins/twitter/plugin.py
import re
import requests
import twitter
from urllib.parse import urlparse
from twisted.internet import defer
from twisted.internet.threads import deferToThread
from cardinal.decorators import event
from cardinal.exceptions import EventRejectedMessage





class TwitterPlugin:
    def __init__(self, config):
        consumer_key = config['consumer_key']
        consumer_secret = config['consumer_secret']

        if not all([consumer_key, consumer_secret]):
            raise Exception(
                "Twitter plugin requires consumer_key and consumer_secret"
            )

        self.api = twitter.Api(
            consumer_key=consumer_key,
            consumer_secret=consumer_secret,
            application_only_auth=True,
        )

    @defer.inlineCallbacks

    def get_tweet(self, tweet_id):