# Path: will/settings.py
# def auto_key():
# def import_settings(quiet=True):
#         DEPRECATED_BUT_MAPPED_SETTINGS = {
#             "USERNAME": "HIPCHAT_USERNAME",
#             "PASSWORD": "HIPCHAT_PASSWORD",
#             "V1_TOKEN": "HIPCHAT_V1_TOKEN",
#             "V2_TOKEN": "HIPCHAT_V2_TOKEN",
#             "TOKEN": "HIPCHAT_V1_TOKEN",
#             "ROOMS": "HIPCHAT_ROOMS",
#             "NAME": "HIPCHAT_NAME",
#             "HANDLE": "HIPCHAT_HANDLE",
#             "DEFAULT_ROOM": "HIPCHAT_DEFAULT_ROOM",
#             "SLACK_DEFAULT_ROOM": "SLACK_DEFAULT_CHANNEL",
#         }
#             IO_BACKENDS = []
# 
# Path: will/decorators.py
# def require_settings(*setting_names):
#     def wrap(f):
#         def wrapped_f(*args, **kwargs):
#             f(*args, **kwargs)
#         wrapped_f.will_fn_metadata = getattr(f, "will_fn_metadata", {})
#         wrapped_f.will_fn_metadata["required_settings"] = setting_names
#         return wrapped_f
#     return wrap
# 
# Path: will/acl.py
# def verify_acl(message, acl):
#     try:
#         if settings.DISABLE_ACL:
#             return True
# 
#         allowed = is_acl_allowed(message.sender.id, acl)
#         if allowed:
#             return True
#         if hasattr(message, "data") and hasattr(message.data, "backend_supports_acl"):
#             if not message.data.backend_supports_acl:
#                 logging.warning(
#                     "%s was just allowed to perform actions in %s because the backend does not support ACL.  This can be a security risk." % (
#                         message.sender.handle,
#                         acl,
#                     ) + "To fix this, set ACL groups in your config.py, or set DISABLE_ACL = True"
#                 )
#                 return True
#     except:
#         pass
# 
#     return False
# 
# Path: will/abstractions.py
# class Event(Bunch):
#     will_internal_type = "Event"
# 
#     REQUIRED_FIELDS = [
#         "type",
#         "version",
#     ]
# 
#     def __init__(self, *args, **kwargs):
#         super(Event, self).__init__(*args, **kwargs)
#         self.version = 1
# 
#         for f in self.REQUIRED_FIELDS:
#             if not f in kwargs and not hasattr(self, f):
#                 raise Exception("Missing %s in Event construction." % f)
# 
#         if "timestamp" in kwargs:
#             self.timestamp = kwargs["timestamp"]
#         else:
#             self.timestamp = datetime.datetime.now()
# 
#         h = hashlib.md5()
#         h.update(self.timestamp.strftime("%s").encode("utf-8"))
#         h.update(self.type.encode("utf-8"))
#         self.hash = h.hexdigest()
#         if not "original_incoming_event_hash" in kwargs:
#             if hasattr(self, "original_incoming_event") and hasattr(self.original_incoming_event, "hash"):
#                 self.original_incoming_event_hash = self.original_incoming_event.hash
#             else:
#                 self.original_incoming_event_hash = self.hash


import imp
import logging
import signal
import traceback
from will import settings
from will.decorators import require_settings
from will.acl import verify_acl
from will.abstractions import Event
from multiprocessing import Process
    def handle_execution(self, message, context):
        raise NotImplementedError

    def no_response(self, message):
        self.bot.pubsub.publish(
            "message.no_response",
            message.data,
            reference_message=message.data.original_incoming_event
        )

    def not_allowed(self, message, explanation):

        self.bot.pubsub.publish(
            "message.outgoing.%s" % message.data.backend,
            Event(
                type="reply",
                content=explanation,
                source_message=message,
            ),
            reference_message=message.data.original_incoming_event
        )

    def execute(self, message, option):
        if "acl" in option.context:
            acl = option.context["acl"]
            if type(acl) == type("test"):
                acl = [acl]

            allowed = True
            if len(acl) > 0:

# Path: will/settings.py
# def auto_key():
# def import_settings(quiet=True):
#         DEPRECATED_BUT_MAPPED_SETTINGS = {
#             "USERNAME": "HIPCHAT_USERNAME",
#             "PASSWORD": "HIPCHAT_PASSWORD",
#             "V1_TOKEN": "HIPCHAT_V1_TOKEN",
#             "V2_TOKEN": "HIPCHAT_V2_TOKEN",
#             "TOKEN": "HIPCHAT_V1_TOKEN",
#             "ROOMS": "HIPCHAT_ROOMS",
#             "NAME": "HIPCHAT_NAME",
#             "HANDLE": "HIPCHAT_HANDLE",
#             "DEFAULT_ROOM": "HIPCHAT_DEFAULT_ROOM",
#             "SLACK_DEFAULT_ROOM": "SLACK_DEFAULT_CHANNEL",
#         }
#             IO_BACKENDS = []
# 
# Path: will/decorators.py
# def require_settings(*setting_names):
#     def wrap(f):
#         def wrapped_f(*args, **kwargs):
#             f(*args, **kwargs)
#         wrapped_f.will_fn_metadata = getattr(f, "will_fn_metadata", {})
#         wrapped_f.will_fn_metadata["required_settings"] = setting_names
#         return wrapped_f
#     return wrap
# 
# Path: will/acl.py
# def verify_acl(message, acl):
#     try:
#         if settings.DISABLE_ACL:
#             return True
# 
#         allowed = is_acl_allowed(message.sender.id, acl)
#         if allowed:
#             return True
#         if hasattr(message, "data") and hasattr(message.data, "backend_supports_acl"):
#             if not message.data.backend_supports_acl:
#                 logging.warning(
#                     "%s was just allowed to perform actions in %s because the backend does not support ACL.  This can be a security risk." % (
#                         message.sender.handle,
#                         acl,
#                     ) + "To fix this, set ACL groups in your config.py, or set DISABLE_ACL = True"
#                 )
#                 return True
#     except:
#         pass
# 
#     return False
# 
# Path: will/abstractions.py
# class Event(Bunch):
#     will_internal_type = "Event"
# 
#     REQUIRED_FIELDS = [
#         "type",
#         "version",
#     ]
# 
#     def __init__(self, *args, **kwargs):
#         super(Event, self).__init__(*args, **kwargs)
#         self.version = 1
# 
#         for f in self.REQUIRED_FIELDS:
#             if not f in kwargs and not hasattr(self, f):
#                 raise Exception("Missing %s in Event construction." % f)
# 
#         if "timestamp" in kwargs:
#             self.timestamp = kwargs["timestamp"]
#         else:
#             self.timestamp = datetime.datetime.now()
# 
#         h = hashlib.md5()
#         h.update(self.timestamp.strftime("%s").encode("utf-8"))
#         h.update(self.type.encode("utf-8"))
#         self.hash = h.hexdigest()
#         if not "original_incoming_event_hash" in kwargs:
#             if hasattr(self, "original_incoming_event") and hasattr(self.original_incoming_event, "hash"):
#                 self.original_incoming_event_hash = self.original_incoming_event.hash
#             else:
#                 self.original_incoming_event_hash = self.hash


# Path: will/backends/execution/base.py
import imp
import logging
import signal
import traceback
from will import settings
from will.decorators import require_settings
from will.acl import verify_acl
from will.abstractions import Event
from multiprocessing import Process

    def handle_execution(self, message, context):
        raise NotImplementedError

    def no_response(self, message):
        self.bot.pubsub.publish(
            "message.no_response",
            message.data,
            reference_message=message.data.original_incoming_event
        )

    def not_allowed(self, message, explanation):

        self.bot.pubsub.publish(
            "message.outgoing.%s" % message.data.backend,
            Event(
                type="reply",
                content=explanation,
                source_message=message,
            ),
            reference_message=message.data.original_incoming_event
        )

    def execute(self, message, option):
        if "acl" in option.context:
            acl = option.context["acl"]
            if type(acl) == type("test"):
                acl = [acl]

            allowed = True
            if len(acl) > 0:

                allowed = verify_acl(message, acl)