コード例 #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],
     }
コード例 #2
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],
     }
コード例 #3
0
ファイル: gitter.py プロジェクト: jayvdb/err-backend-gitter
    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()
コード例 #8
0
    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
ファイル: gitter.py プロジェクト: errbotio/err-backend-gitter
    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
ファイル: md_rendering_test.py プロジェクト: Adman/errbot
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()