# 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/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
# 
# class Message(object):
#     will_internal_type = "Message"
#     REQUIRED_FIELDS = [
#         "is_direct",
#         "is_private_chat",
#         "is_group_chat",
#         "will_is_mentioned",
#         "will_said_it",
#         "sender",
#         "backend_supports_acl",
#         "content",
#         "backend",
#         "original_incoming_event",
#     ]
# 
#     def __init__(self, *args, **kwargs):
#         for f in self.REQUIRED_FIELDS:
#             if not f in kwargs:
#                 raise Exception("Missing %s in Message construction." % f)
# 
#         for f in kwargs:
#             self.__dict__[f] = kwargs[f]
# 
#         if "timestamp" in kwargs:
#             self.timestamp = kwargs["timestamp"]
#         else:
#             self.timestamp = datetime.datetime.now()
# 
#         # Clean content.
#         self.content = self._clean_message_content(self.content)
# 
#         h = hashlib.md5()
#         h.update(self.timestamp.strftime("%s").encode("utf-8"))
#         h.update(self.content.encode("utf-8"))
#         self.hash = h.hexdigest()
# 
#         self.metadata = Bunch()
#         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
# 
#     def __unicode__(self, *args, **kwargs):
#         if len(self.content) > 20:
#             content_str = "%s..." % self.content[:20]
#         else:
#             content_str = self.content
#         return u"Message: \"%s\"\n  %s (%s) " % (
#             content_str,
#             self.timestamp.strftime('%Y-%m-%d %H:%M:%S'),
#             self.backend,
#         )
# 
#     def __str__(self, *args, **kwargs):
#         return self.__unicode__(*args, **kwargs)
# 
#     def _clean_message_content(self, s):
#         # Clear out 'smart' quotes and the like.
#         s = s.replace("’", "'").replace("‘", "'").replace('“', '"').replace('”', '"')
#         s = s.replace(u"\u2018", "'").replace(u"\u2019", "'")
#         s = s.replace(u"\u201c", '"').replace(u"\u201d", '"')
#         return s


import re
import logging
from bottle import request
from will import settings
from will.abstractions import Event, Message
from will.mixins import NaturalTimeMixin, ScheduleMixin, StorageMixin, SettingsMixin, \
    EmailMixin, PubSubMixin
            e = Event(
                type="say",
                content=content,
                source_message=message,
                kwargs=kwargs,
            )
            if package_for_scheduling:
                return "message.outgoing.%s" % backend, e
            logging.info("putting in queue: %s", content)
            self.publish("message.outgoing.%s" % backend, e)
        return None

    def send_file(self, message, content, filename, text=None, filetype='text',
                  service=None, room=None, channel=None, **kwargs):
        'Sometimes you need to upload an image or file'
        if channel:
            room = channel
        elif room:
            channel = room

        if "channel" not in kwargs and channel:
            kwargs["channel"] = channel

        message = self.get_message(message)
        message = self._trim_for_execution(message)
        backend = self.get_backend(message, service=service)

        if backend:
            if isinstance(content, str):
                content = content.encode('utf-8')

# 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/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
# 
# class Message(object):
#     will_internal_type = "Message"
#     REQUIRED_FIELDS = [
#         "is_direct",
#         "is_private_chat",
#         "is_group_chat",
#         "will_is_mentioned",
#         "will_said_it",
#         "sender",
#         "backend_supports_acl",
#         "content",
#         "backend",
#         "original_incoming_event",
#     ]
# 
#     def __init__(self, *args, **kwargs):
#         for f in self.REQUIRED_FIELDS:
#             if not f in kwargs:
#                 raise Exception("Missing %s in Message construction." % f)
# 
#         for f in kwargs:
#             self.__dict__[f] = kwargs[f]
# 
#         if "timestamp" in kwargs:
#             self.timestamp = kwargs["timestamp"]
#         else:
#             self.timestamp = datetime.datetime.now()
# 
#         # Clean content.
#         self.content = self._clean_message_content(self.content)
# 
#         h = hashlib.md5()
#         h.update(self.timestamp.strftime("%s").encode("utf-8"))
#         h.update(self.content.encode("utf-8"))
#         self.hash = h.hexdigest()
# 
#         self.metadata = Bunch()
#         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
# 
#     def __unicode__(self, *args, **kwargs):
#         if len(self.content) > 20:
#             content_str = "%s..." % self.content[:20]
#         else:
#             content_str = self.content
#         return u"Message: \"%s\"\n  %s (%s) " % (
#             content_str,
#             self.timestamp.strftime('%Y-%m-%d %H:%M:%S'),
#             self.backend,
#         )
# 
#     def __str__(self, *args, **kwargs):
#         return self.__unicode__(*args, **kwargs)
# 
#     def _clean_message_content(self, s):
#         # Clear out 'smart' quotes and the like.
#         s = s.replace("’", "'").replace("‘", "'").replace('“', '"').replace('”', '"')
#         s = s.replace(u"\u2018", "'").replace(u"\u2019", "'")
#         s = s.replace(u"\u201c", '"').replace(u"\u201d", '"')
#         return s


# Path: will/plugin.py
import re
import logging
from bottle import request
from will import settings
from will.abstractions import Event, Message
from will.mixins import NaturalTimeMixin, ScheduleMixin, StorageMixin, SettingsMixin, \
    EmailMixin, PubSubMixin

            e = Event(
                type="say",
                content=content,
                source_message=message,
                kwargs=kwargs,
            )
            if package_for_scheduling:
                return "message.outgoing.%s" % backend, e
            logging.info("putting in queue: %s", content)
            self.publish("message.outgoing.%s" % backend, e)
        return None

    def send_file(self, message, content, filename, text=None, filetype='text',
                  service=None, room=None, channel=None, **kwargs):
        'Sometimes you need to upload an image or file'
        if channel:
            room = channel
        elif room:
            channel = room

        if "channel" not in kwargs and channel:
            kwargs["channel"] = channel

        message = self.get_message(message)
        message = self._trim_for_execution(message)
        backend = self.get_backend(message, service=service)

        if backend:
            if isinstance(content, str):
                content = content.encode('utf-8')

            e = Event(