コード例 #1
0
ファイル: app.py プロジェクト: GRIT-elysianblue/Shuffle-apps
    async def send_actionable_msg(self, webhook_url, title, message,
                                  callback_url):
        try:
            myTeamsMessage = teams.connectorcard(
                webhook_url
            )  # You must create the connectorcard object with the Microsoft Webhook URL
            myTeamsMessage.title(title)  # title for your card
            myTeamsMessage.text(message)  # Add text to the message.
            myTeamsPotentialAction3 = teams.potentialaction(
                _name="Select_Action")
            myTeamsPotentialAction3.choices.addChoices("Accept",
                                                       "Accept")  #option 1
            myTeamsPotentialAction3.choices.addChoices("Reject",
                                                       "Reject")  #option 2
            myTeamsPotentialAction3.addInput("MultichoiceInput", "list",
                                             "Select Action",
                                             False)  #Dropdown menu
            myTeamsPotentialAction3.addAction(
                "HttpPost", "Submit", callback_url)  #post request to Shuffle
            myTeamsMessage.addPotentialAction(myTeamsPotentialAction3)
            myTeamsMessage.send()  # send the message.
        except Exception as e:
            return f'{e} occured'

        return f'Message Sent'
コード例 #2
0
ファイル: app.py プロジェクト: dhaval055/Shuffle-apps
    def send_actionable_msg(self, webhook_url, title, message, added_information, choices, callback_url):
        try:
            myTeamsMessage = teams.connectorcard(webhook_url)    # You must create the connectorcard object with the Microsoft Webhook URL
            myTeamsMessage.title(title) # title for your card
            myTeamsMessage.text(message)     # Add text to the message.
            myTeamsPotentialAction3 = teams.potentialaction(_name = "Select_Action")

            if choices:
                for choice in choices.split(","):
                    choice = choice.strip()
                    value = {
                        "choice": choice,
                        "extra": added_information,
                    }

                    try:
                        choice_value = json.dumps(value)
                    except:
                        print("FAILED ENCODING {}".format(choice))
                        choice_value = choice

                    myTeamsPotentialAction3.choices.addChoices(choice, choice_value) #option 1

            else:
                value = {
                    "choice": "ACCEPT",
                    "extra": added_information,
                }

                #print(f"VALUE: {value}")

                try:
                    accept = json.dumps(value)
                except:
                    print("FAILED ENCODING ACCEPT")
                    accept = "ACCEPT"

                myTeamsPotentialAction3.choices.addChoices("Accept", accept) #option 1

                value["choice"] = "REJECT"
                try:
                    deny = json.dumps(value)
                except:
                    print("FAILED ENCODING REJECT")
                    deny = "REJECT"

                myTeamsPotentialAction3.choices.addChoices("Reject", deny) #option 2

            myTeamsPotentialAction3.addInput("MultichoiceInput","list","Select Action", False) #Dropdown menu
            myTeamsPotentialAction3.addAction("HttpPost","Submit",callback_url) #post request to Shuffle
            myTeamsMessage.addPotentialAction(myTeamsPotentialAction3)
            myTeamsMessage.send()# send the message.
        except Exception as e:
            return f'{e} occured'
        
        return f'Message Sent'        
コード例 #3
0
ファイル: app.py プロジェクト: dhaval055/Shuffle-apps
    def get_user_input(self, webhook_url, title, message, callback_url):
        try:
            myTeamsMessage = teams.connectorcard(webhook_url)  # You must create the connectorcard object with the Microsoft Webhook URL
            myTeamsMessage.title(title) # Title for your card
            myTeamsMessage.text(message) # Add text to the message.
            myTeamsPotentialAction1 = teams.potentialaction(_name = "Comment")
            myTeamsPotentialAction1.addInput("TextInput","comment", "Your text here..",False)
            myTeamsPotentialAction1.addCommentAction("HttpPost","Submit", callback_url)
            myTeamsMessage.addPotentialAction(myTeamsPotentialAction1)
            myTeamsMessage.send()
        except Exception as e:
            return f'{e.__class__} occured'

        return f'Message Sent'