teams-webhook/examples/multipleoptions.py

33 lines
1.4 KiB
Python

#!/usr/bin/env python
import sys,os
sys.path.append('../')
import teamswebhook as twh
myhook = twh.MessageCard()
myhook.channel_uri = 'https://outlook.office.com/webhook/CHANNELUUID/IncomingWebhook/WEBHOOKUUID'
data = [
{'Router': 'crN-lllN'},
{'SomeText': 'Some other text'},
{'Preformatted': '<pre>\nsome output\n\twith an indent\n</pre>'}
]
myhook.title = 'Some title of a message'
myhook.subtitle = 'Some example subtitle'
# Select an icon from icons.json array or put a URL/Base64 string
#myhook.icon = twh.stock_icons['cute']['firewall']
#myhook.icon = twh.stock_icons['gradient']['system_task']
myhook.AddFacts(data)
myhook.AddMultichoice({'action_id': 'multichoice', 'action_name': 'This is a MultiChoice Multiselect', 'button_label': 'Submit Choices', 'input_hint': 'Select all that apply', 'choices': [{'display': 'One', 'value': 1},{'display': 'Two', 'value': 2},{'display': 'Three', 'value': 13}], 'post_uri': 'https://example.com/postme', 'multiselect': True})
myhook.AddMultichoice({'action_id': 'multichoice', 'action_name': 'This is a MultiChoice Singleselect', 'button_label': 'Submit Choice', 'input_hint': 'Select One', 'choices': [{'display': 'One', 'value': 1},{'display': 'Two', 'value': 2},{'display': 'Three', 'value': 13}], 'post_uri': 'https://example.com/postme'})
# Sends to Office365
myhook.SendCard()
# Prints out the JSON Card information
#myhook.PrintJSON()