Пример #1
0
 def __init__(self, config):
     super().__init__(config)
     identity = config.BOT_IDENTITY
     self._login = identity.get('login', None)
     self._password = identity.get('password', None)
     self._personal_access_token = identity.get('token', None)
     self._mfa_token = identity.get('mfa_token', None)
     self.team = identity.get('team')
     self._scheme = identity.get('scheme', 'https')
     self._port = identity.get('port', 8065)
     self.cards_hook = identity.get('cards_hook', None)
     self.url = identity.get('server').rstrip('/')
     self.insecure = identity.get('insecure', False)
     self.timeout = identity.get('timeout', DEFAULT_TIMEOUT)
     self.teamid = ''
     self.token = ''
     self.bot_identifier = None
     self.driver = None
     self.md = md()
     self.event_handlers = {
         'posted': [self._message_event_handler],
         'status_change': [self._status_change_event_handler],
         'hello': [self._hello_event_handler],
         'user_added': [self._room_joined_event_handler],
         'user_removed': [self._room_left_event_handler],
     }
 def __init__(self, config):
     super().__init__(config)
     identity = config.BOT_IDENTITY
     self._login = identity.get("login", None)
     self._password = identity.get("password", None)
     self._personal_access_token = identity.get("token", None)
     self._mfa_token = identity.get("mfa_token", None)
     self.team = identity.get("team")
     self._scheme = identity.get("scheme", "https")
     self._port = identity.get("port", 8065)
     self.cards_hook = identity.get("cards_hook", None)
     self.url = identity.get("server").rstrip("/")
     self.insecure = identity.get("insecure", False)
     self.timeout = identity.get("timeout", DEFAULT_TIMEOUT)
     self.teamid = ""
     self.token = ""
     self.bot_identifier = None
     self.driver = None
     self.md = md()
     self.event_handlers = {
         "posted": [self._message_event_handler],
         "status_change": [self._status_change_event_handler],
         "hello": [self._hello_event_handler],
         "user_added": [self._room_joined_event_handler],
         "user_removed": [self._room_left_event_handler],
     }
Пример #3
0
    def __init__(self, config):
        super().__init__(config)
        if config.MESSAGE_SIZE_LIMIT > GITTER_MESSAGE_SIZE_LIMIT:
            log.info(
                "Capping MESSAGE_SIZE_LIMIT to %s which is the maximum length allowed by Gitter",
                GITTER_MESSAGE_SIZE_LIMIT)
            config.MESSAGE_SIZE_LIMIT = GITTER_MESSAGE_SIZE_LIMIT
        self.md = md()
        identity = config.BOT_IDENTITY

        self.token = identity.get('token', None)
        self.rooms_to_join = config.CHATROOM_PRESENCE

        if not self.token:
            log.fatal(
                'You need to set your auth token in the BOT_IDENTITY setting of '
                'your configuration. To obtain it, execute the included oauth.py '
                'script')
            sys.exit(1)
        self.base_headers = {
            'Authorization': 'Bearer ' + self.token,
            'Accept': 'application/json'
        }
        self.bot_identifier = self._get_bot_identifier()

        self._joined_rooms_lock = threading.Lock()
        self._joined_rooms = []
Пример #4
0
    def __init__(self, token):

        bot_identity = BOT_IDENTITY = {
            'TOKEN': token,
        }
        self.md = rendering.md()

        # Do we have the basic mandatory config needed to operate the bot
        self._bot_token = bot_identity.get('TOKEN', None)
        if not self._bot_token:
            log.fatal('You need to define the Cisco Webex Teams Bot TOKEN in the BOT_IDENTITY of config.py.')
            sys.exit(1)

        print("Setting up SparkAPI")
        self.webex_teams_api = webexteamssdk.WebexTeamsAPI(access_token=self._bot_token)

        print("Setting up device on Webex Teams")
        self.device_info = self._get_device_info()

        print("Fetching and building identifier for the bot itself.")
        self.bot_identifier = CiscoWebexTeamsPerson(self, self.webex_teams_api.people.me())

        print("Done! I'm connected as {}".format(self.bot_identifier.email))

        self._register_identifiers_pickling()
Пример #5
0
 def __init__(self, config):
     super().__init__(config)
     identity = config.BOT_IDENTITY
     self._email = identity.get('email')
     self._password = identity.get('password')
     self.url = identity.get('server').rstrip('/')
     self.insecure = identity.get('insecure', False)
     self.timeout = identity.get('timeout', DEFAULT_TIMEOUT)
     self.team = identity.get('team')
     self.teamid = ''
     self.token = ''
     self.bot_identifier = None
     self.client = None
     self.md = md()
Пример #6
0
	def __init__(self, config):
		super().__init__(config)
		identity = config.BOT_IDENTITY
		self._login = identity.get('login', None)
		self._password = identity.get('password', None)
		self._personal_access_token = identity.get('token', None)
		self._mfa_token = identity.get('mfa_token', None)
		self.team = identity.get('team')
		self._scheme = identity.get('scheme', 'https')
		self._port = identity.get('port', 8065)
		self.cards_hook = identity.get('cards_hook', None)
		self.url = identity.get('server').rstrip('/')
		self.insecure = identity.get('insecure', False)
		self.timeout = identity.get('timeout', DEFAULT_TIMEOUT)
		self.teamid = ''
		self.token = ''
		self.bot_identifier = None
		self.driver = None
		self.md = md()
Пример #7
0
    def __init__(self, config):
        super().__init__(config)
        config.MESSAGE_SIZE_LIMIT = TELEGRAM_MESSAGE_SIZE_LIMIT
        logging.getLogger('telegram.bot').addFilter(TelegramBotFilter())

        identity = config.BOT_IDENTITY
        self.token = identity.get('token', None)
        if not self.token:
            log.fatal(
                "You need to supply a token for me to use. You can obtain "
                "a token by registering your bot with the Bot Father (@BotFather)"
            )
            sys.exit(1)
        self.telegram = None  # Will be initialized in serve_once
        self.bot_instance = None  # Will be set in serve_once

        compact = config.COMPACT_OUTPUT if hasattr(config,
                                                   'COMPACT_OUTPUT') else False
        enable_format('text', TEXT_CHRS, borders=not compact)
        #self.md_converter = text()
        self.md_converter = md()
    def __init__(self, config):

        super().__init__(config)

        bot_identity = config.BOT_IDENTITY

        self.md = rendering.md()

        # Do we have the basic mandatory config needed to operate the bot
        self._bot_token = bot_identity.get("TOKEN", None)
        if not self._bot_token:
            log.fatal(
                "You need to define the Cisco Webex Teams Bot TOKEN in the BOT_IDENTITY of config.py."
            )
            sys.exit(1)

        # Adjust message size limit to cater for the non-standard size limit
        if config.MESSAGE_SIZE_LIMIT > CISCO_WEBEX_TEAMS_MESSAGE_SIZE_LIMIT:
            log.info(
                "Capping MESSAGE_SIZE_LIMIT to {} which is the maximum length allowed by CiscoWebexTeams".format(
                    CISCO_WEBEX_TEAMS_MESSAGE_SIZE_LIMIT
                )
            )
            config.MESSAGE_SIZE_LIMIT = CISCO_WEBEX_TEAMS_MESSAGE_SIZE_LIMIT

        log.debug("Setting up SparkAPI")
        self.webex_teams_api = webexteamssdk.WebexTeamsAPI(access_token=self._bot_token)

        log.debug("Setting up device on Webex Teams")
        self.device_info = self._get_device_info()

        log.debug("Fetching and building identifier for the bot itself.")
        self.bot_identifier = CiscoWebexTeamsPerson(
            self, self.webex_teams_api.people.me()
        )

        log.debug("Done! I'm connected as {}".format(self.bot_identifier.email))

        self._register_identifiers_pickling()
Пример #9
0
    def __init__(self, config):
        super().__init__(config)
        if config.MESSAGE_SIZE_LIMIT > GITTER_MESSAGE_SIZE_LIMIT:
            log.info(
                "Capping MESSAGE_SIZE_LIMIT to %s which is the maximum length allowed by Gitter",
                GITTER_MESSAGE_SIZE_LIMIT
            )
            config.MESSAGE_SIZE_LIMIT = GITTER_MESSAGE_SIZE_LIMIT
        self.md = md()
        identity = config.BOT_IDENTITY

        self.token = identity.get('token', None)
        self.rooms_to_join = config.CHATROOM_PRESENCE

        if not self.token:
            log.fatal(
                    'You need to set your auth token in the BOT_IDENTITY setting of '
                    'your configuration. To obtain it, execute the included oauth.py '
                    'script'
            )
            sys.exit(1)
        self.base_headers = {'Authorization': 'Bearer ' + self.token,
                             'Accept': 'application/json'}
        self.bot_identifier = self._get_bot_identifier()
Пример #10
0
 def test_mde2md(self):
     mdc = md()
     self.assertEquals(mdc.convert("woot"), "woot")
     self.assertEquals(mdc.convert("woot{stuff} really{otherstuff}"), "woot really")
Пример #11
0
def test_mde2md():
    mdc = rendering.md()
    assert mdc.convert("woot") == "woot"
    assert mdc.convert("woot{:stuff} really{:otherstuff}") == "woot really"
Пример #12
0
def test_mde2md():
    mdc = rendering.md()
    assert mdc.convert("woot") == "woot"
    assert mdc.convert("woot{:stuff} really{:otherstuff}") == "woot really"
Пример #13
0
 def __init__(self, config):
     super().__init__(config)
     self.spark = sparkpy.Spark(config.BOT_IDENTITY)
     self.md = md()  # Needed to convert from markdown extra to markdown
     self.build_alt_prefixes()
Пример #14
0
 def __init__(self, config):
     super().__init__(config)
     self.spark = sparkpy.Spark(config.BOT_IDENTITY)
     self.md = md()  # Needed to convert from markdown extra to markdown
     self.build_alt_prefixes()