import pymsteams
import logging
from oncall.constants import TEAMS_SUPPORT


class teams_messenger(object):
    supports = frozenset([TEAMS_SUPPORT])

    def __init__(self, config):
        self.webhook = config['webhook']

    def send(self, message):
        heading = message.get("subject")
        final_message = "User: " + message.get("user") + " Message: " + message.get("body")

        try:
            myTeamsMessage = pymsteams.connectorcard(self.webhook)
            myTeamsMessage.title(str(heading))
            myTeamsMessage.text(str(final_message))
            myTeamsMessage.send()
        except:
            logging.info("An issue occured while sending message to teams messenger")

[((17, 29, 17, 66), 'pymsteams.connectorcard', 'pymsteams.connectorcard', ({(17, 53, 17, 65): 'self.webhook'}, {}), '(self.webhook)', False, 'import pymsteams\n'), ((22, 12, 22, 85), 'logging.info', 'logging.info', ({(22, 25, 22, 84): '"""An issue occured while sending message to teams messenger"""'}, {}), "('An issue occured while sending message to teams messenger')", False, 'import logging\n')]