def test_process_incoming_membership_check_sender_pass(self, m): m.get('https://api.ciscospark.com/v1/webhooks', json=MockTeamsAPI.list_webhooks()) m.post('https://api.ciscospark.com/v1/webhooks', json=MockTeamsAPI.create_webhook()) m.post('//api.ciscospark.com/v1/messages', json={}) bot_email = "*****@*****.**" teams_token = "somefaketoken" bot_url = "http://fakebot.com" bot_app_name = "testbot" # Create a new bot bot = TeamsBot(bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, webhook_resource="memberships", webhook_event="all") # Add new command bot.add_command('memberships', '*', self.check_membership) bot.testing = True self.app = bot.test_client() resp = self.app.post('/', data=MockTeamsAPI.incoming_membership_pass(), content_type="application/json") self.assertEqual(resp.status_code, 200) print(resp.data) self.assertIn(b"success", resp.data)
def test_bad_config_raises_valueerror(self, m): with self.assertRaises(ValueError): m.get( "https://api.ciscospark.com/v1/webhooks", json=MockTeamsAPI.list_webhooks_exist(), ) m.post( "https://api.ciscospark.com/v1/webhooks", json=MockTeamsAPI.create_webhook(), ) bot_email = None teams_token = "somefaketoken" bot_url = "http://fakebot.com" bot_app_name = "testbot" # Create a new bot bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, ) # Add new command bot.add_command("/dosomething", "help for do something", self.do_something) bot.testing = True self.app = bot.test_client()
def test_webhook_already_exists(self, m): m.get( "https://api.ciscospark.com/v1/webhooks", json=MockTeamsAPI.list_webhooks_exist(), ) m.post( "https://api.ciscospark.com/v1/webhooks", json=MockTeamsAPI.create_webhook(), ) bot_email = "*****@*****.**" teams_token = "somefaketoken" bot_url = "http://fakebot.com" bot_app_name = "testbot" # Create a new bot bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, ) # Add new command bot.add_command("/dosomething", "help for do something", self.do_something) bot.testing = True self.app = bot.test_client()
# Create a Bot Object # Note: debug mode prints out more details about processing to terminal # Note: the `approved_users=approved_users` line commented out and shown as reference bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, # approved_users=approved_users, webhook_resource="memberships", webhook_resource_event=[ { "resource": "messages", "event": "created" }, { "resource": "attachmentActions", "event": "created" }, { "resource": "memberships", "event": "created" }, ], ) def load_allowedusers(): print("load users here")
print("TEAMS_BOT_APP_NAME") sys.exit() # Create a Bot Object # Note: debug mode prints out more details about processing to terminal # Note: the `admin_users=admin_users` line commented out and shown as reference # Note: the `approved_users=approved_users` line commented out and shown as reference bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, # admin_users=admin_users, # approved_users=approved_users, webhook_resource_event=[ {"resource": "messages", "event": "created"}, {"resource": "attachmentActions", "event": "created"}, ], o365_client_id=o365_client_id, o365_client_token=o365_client_token, o365_tenant_id=o365_tenant_id, o365_scopes=o365_scopes, ) # Create a custom bot greeting function returned when no command is given. # The default behavior of the bot is to return the '/help' command response def greeting(incoming_msg): # Loopkup details about sender sender = bot.teams.people.get(incoming_msg.personId)
if not bot_app_name: print("TEAMS_BOT_APP_NAME") sys.exit() # Create a Bot Object # Note: debug mode prints out more details about processing to terminal # Note: the `approved_users=approved_users` line commented out and shown as reference bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, # approved_users=approved_users, webhook_resource_event=[ { "resource": "messages", "event": "created" }, { "resource": "attachmentActions", "event": "created" }, ], ) def botgreeting(incoming_msg): sender = bot.teams.people.get(incoming_msg.personId) response = Response()
load_dotenv() # Retrieve required details from environment variables bot_email = os.getenv("OCTO_BOT_EMAIL") bot_id = os.getenv("OCTO_BOT_ID") teams_token = os.getenv("OCTO_BOT_TOKEN") bot_url = os.getenv("OCTO_BOT_URL") bot_app_name = os.getenv("OCTO_BOT_APP_NAME") o365_token = os.getenv("O365_TOKEN") # Create a Bot Object bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, webhook_resource_event=[{"resource": "messages", "event": "created"}, {"resource": "attachmentActions", "event": "created"}] ) # Create a custom bot greeting function returned when no command is given. # The default behavior of the bot is to return the '/help' command response def greeting(incoming_msg): # Loopkup details about sender sender = bot.teams.people.get(incoming_msg.personId) # Create a Response object and craft a reply in Markdown. response = Response() response.markdown = "Hello {}, I'm a chat bot. ".format(sender.firstName) response.markdown += "See what I can do by asking for **/help**."
#quick_guest(name) config.read(os.path.join(os.path.dirname(__file__), 'volume', 'config.cfg')) bot_email = config["Webex"]["TEAMS_BOT_EMAIL"] teams_token = config["Webex"]["TEAMS_BOT_TOKEN"] bot_url = config["Webex"]["TEAMS_BOT_URL"] bot_app_name = config["Webex"]["TEAMS_BOT_APP_NAME"] bot = TeamsBot(bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, webhook_resource_event=[{ "resource": "messages", "event": "created" }, { "resource": "attachmentActions", "event": "created" }]) name = '' bot.add_command("/quick_guest", "help for do something", do_something) if __name__ == "__main__": # Run Bot bot.run(host="0.0.0.0", port=5000, debug=True) schedule.every().day.at("18:00").do( os.system('/usr/bin/python3 fmc_clean_access_policy.py')) while True:
bot_url = os.getenv("COB_BOT_URL") bot_app_name = os.getenv("COB_BOT_APP_NAME") meraki_api_key = os.getenv("MERAKI_API_KEY") umbrella_management_key = os.getenv("UMBRELLA_MANAGEMENT_KEY") umbrella_management_secret = os.getenv("UMBRELLA_MANAGEMENT_SECRET") umbrella_org_id = os.getenv("UMBRELLA_ORG_ID") image_upload_url = os.getenv("IMAGE_UPLOAD_URL") media_path = os.getenv("MEDIA_PATH") # Create a Bot Object bot = TeamsBot(bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, webhook_resource_event=[{ "resource": "messages", "event": "created" }, { "resource": "attachmentActions", "event": "created" }]) # Create a custom bot greeting function returned when no command is given. # The default behavior of the bot is to return the '/help' command response def greeting(incoming_msg): # Loopkup details about sender sender = bot.teams.people.get(incoming_msg.personId) # Create a Response object and craft a reply in Markdown. response = Response()
############## ### Bot setup ############## auth = str.encode(':'.join((ISE_USER, ISE_PW))) authkey = bytes.decode(base64.b64encode(auth)) headers = { 'AUTHORIZATION': 'Basic ' + authkey, 'Content-Type': 'application/json', 'Accept': 'application/json' } bot = TeamsBot( BOT_APP_NAME, teams_bot_token=ACCESS_TOKEN, teams_bot_url=BOT_URL, teams_bot_email=BOT_EMAIL, ) def runbot(): # Add bot commands bot.add_command("/listusers", "List all non-expired guest users", list_users) bot.add_command("/adduser", "Add a new guest user", add_user) bot.add_command("/deluser", "Delete a guest user", del_user) bot.add_command("/finduser", "Return information for a guest user", find_user) # Remove echo command bot.remove_command("/echo") # Set bot greeting (returned if no command is recognized)
from webexteamsbot import TeamsBot from webexteamsbot.models import Response import requests import json import random # Retrieve required details from environment variables bot_email = os.getenv("TEAMS_BOT_EMAIL") teams_token = os.getenv("TEAMS_BOT_TOKEN") bot_url = os.getenv("TEAMS_BOT_URL") bot_app_name = os.getenv("TEAMS_BOT_APP_NAME") # Create a Bot Object bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, ) # set the apikey and limit key = 'TENORAPIKEY' apikey = os.getenv(key) lmt = 1 portkey = 'PORT' port = os.getenv(key) # A simple command that returns a basic string that will be sent as a reply def do_something(incoming_msg): """
from webexteamsbot import TeamsBot import json import requests from tinydb import TinyDB, Query from datetime import datetime db= TinyDB('DB/db.json') bot_token = 'Zjk3NTY0MzgtNjI1Mi00MDE1LWFmODEtYWUwYzRiOGNhNTgzODYwNWI3NWQtNDE1_PF84_1eb65fdf-9643-417f-9974-ad72cae0e10f' bot_name = 'poppy' bot_email = '*****@*****.**' bot_url = 'https://f957cf12.ngrok.io' bot = TeamsBot( bot_name, teams_bot_token=bot_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, webhook_resource_event=[{"resource":"messages", "event":"created"}, {"resource":"attachmentActions","event":"created"}]) lunch_card = """ { "contentType": "application/vnd.microsoft.card.adaptive", "content": { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.0", "body": [ { "type": "TextBlock", "text": "Plans for lunch", "size": "Large",
response.markdown += "You can get a list of commands by typing **/help**." return response if __name__ == "__main__": # Set Webex Teams bot data fromn json file script_dir = os.path.dirname(__file__) bot_file = "{}\\bot.json".format(script_dir) with open(bot_file) as data_file: bot_json = json.load(data_file) bot_url = bot_json["bot_url"] bot_token = bot_json["bot_token"] bot_email = bot_json["bot_email"] bot_name = bot_json["bot_name"] # Create bot instance; Setting debug on bot = TeamsBot( bot_name, teams_bot_token = bot_token, teams_bot_url = bot_url, teams_bot_email = bot_email, debug = True ) # Create bot commands bot.add_command("/ping", "Send a ping, get a pong.", ping) bot.set_greeting(greeting) # Start bot using ngrok bot.run(host="0.0.0.0", port=5000)
from webexteamsbot import TeamsBot from webexteamsbot.models import Response import json import os # Note: Formatting in Webex Teams uses **text** for bold and *text* for italic if __name__ == "__main__": # Set Webex Teams bot data fromn json file script_dir = os.path.dirname(__file__) bot_file = "{}\\bot.json".format(script_dir) with open(bot_file) as data_file: bot_json = json.load(data_file) bot_url = bot_json["bot_url"] bot_token = bot_json["bot_token"] bot_email = bot_json["bot_email"] bot_name = bot_json["bot_name"] # Create bot instance; Setting debug on bot = TeamsBot( bot_name, teams_bot_token = bot_token, teams_bot_url = bot_url, teams_bot_email = bot_email, debug = True ) # Start bot using ngrok bot.run(host="0.0.0.0", port=5000)
def main(): logging.basicConfig(level=logging.DEBUG) ngrok = ngrokhelper.NgrokHelper(port=5000) bot_url = ngrok.start() logging.debug(f'Bot url: {bot_url}') # Create a new bot bot = TeamsBot(bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True) # Spark API api = webexteamssdk.WebexTeamsAPI(teams_token) # Add new command bot.add_command('/chuck', 'get Chuck Norris joke', get_joke) bot.add_command('/traffic', 'show traffic cams', functools.partial(traffic, api)) bot.add_command('/number', 'get fun fact for a number', functools.partial(number, api)) bot.add_command('/dilbert', 'get random dilbert comic', functools.partial(dilbert, api)) bot.add_command('/peanuts', 'get random peanuts comic', peanuts) # run bot bot.run(host='0.0.0.0', port=5000)
# Retrieve required details from environment variables bot_email = "*****@*****.**" bot_token = "" bot_url = "" #try with ngrok.io bot_app_name = "" m = manager.connect(host="", port=830, username="", password="", hostkey_verify=False) # Create a Bot Object bot = TeamsBot( bot_app_name, teams_bot_token=bot_token, teams_bot_url=bot_url, teams_bot_email=bot_email, ) # The bot returns the hostname and IOS version of the device def getinfo(incoming_msg): netconf_reply = m.get_config(source='running') netconf_data = xmltodict.parse(netconf_reply.xml) return "Hostname: {}, IOS Version: {}".format( netconf_data["rpc-reply"]["data"]["native"]["hostname"], netconf_data["rpc-reply"]["data"]["native"]["version"]) # The bot returns all interfaces of the device def getallinterfaces(incoming_msg):
# MQTT broker credentials client = mqtt.Client("") client.tls_set("", tls_version=2) client.username_pw_set("", "") client.connect("", , ) # Cisco Webex Teams Infos bot_email = "*****@*****.**" bot_token = "" bot_url = "" bot_app_name = "" webexAPI = WebexTeamsAPI(access_token=bot_token) # Create the Bot Object bot = TeamsBot(bot_app_name,teams_bot_token=bot_token,teams_bot_url=bot_url,teams_bot_email=bot_email) #allow CORS for the website CORS(bot) # Create Logs # for the future - not implemented yet #logger = logging.getLogger() #logger.setLevel(logging.INFO) """ MQTT FUNCTIONS """ def on_message(client, userdata, message): # Get JSON data into a dict
LINE_SPACING_PX = 2 BORDER_PADDING_PX = 6 MAX_WIDTH_PX = 950 MAX_HEIGHT_PX = 600 IMAGE_FONT = ImageFont.truetype('cour.ttf', FONT_HEIGHT_SIZE_PX) # Retrieve required details from environment variables bot_email = os.getenv("TEAMS_BOT_EMAIL") teams_token = os.getenv("TEAMS_BOT_TOKEN") bot_url = os.getenv("TEAMS_BOT_URL") bot_app_name = os.getenv("TEAMS_BOT_APP_NAME") # Create a Bot Object bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, ) # A simple command that returns a basic string that will be sent as a reply def create_image(incoming_msg): """ Function to create an image based on . :param incoming_msg: The incoming message object from Teams :return: A text or markdown based reply """ image_filename = 'output.png' img = Image.new('RGB', (220, 220), color=('white')) drawing = ImageDraw.Draw(img) drawing.text((BORDER_PADDING_PX, 10),
import requests from webexteamsbot import TeamsBot from webexteamsbot.models import Response # Retrieve required details from environment variables bot_email = os.getenv("TEAMS_BOT_EMAIL") teams_token = os.getenv("TEAMS_BOT_TOKEN") bot_url = os.getenv("TEAMS_BOT_URL") bot_app_name = os.getenv("TEAMS_BOT_APP_NAME") # Create a Bot Object # Note: debug mode prints out more details about processing to terminal bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, ) # Create a custom bot greeting function returned when no command is given. # The default behavior of the bot is to return the '/help' command response def greeting(incoming_msg): # Loopkup details about sender sender = bot.teams.people.get(incoming_msg.personId) # Create a Response object and craft a reply in Markdown. response = Response() response.markdown = "Hello {}, I'm a chat bot. ".format(sender.firstName) response.markdown += "See what I can do by asking for **/help**."
device_type = os.getenv("DEVICE_TYPE") device_username = os.getenv("DEVICE_USERNAME") device_password = os.getenv("DEVICE_PASSWORD") # Setup pyATS and Genie device testbed = testbed_file testbed = loader.load(testbed) testbed = Genie.init(testbed) device = testbed.devices[device_name] # Create a Bot Object # Note: debug mode prints out more details about processing to terminal bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, ) # Create a function to respond to messages that lack any specific command # The greeting will be friendly and suggest how folks can get started. def greeting(incoming_msg): # Loopkup details about sender sender = bot.teams.people.get(incoming_msg.personId) # Retrieve Platform details platform = get_platform_info(device) # Create a Response object and craft a reply in Markdown.
if not bot_app_name: print("TEAMS_BOT_APP_NAME") sys.exit() # Create a Bot Object # Note: debug mode prints out more details about processing to terminal # Note: the `approved_users=approved_users` line commented out and shown as reference bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, # approved_users=approved_users, webhook_resource_event=[ { "resource": "messages", "event": "created" }, { "resource": "attachmentActions", "event": "created" }, ], ) # Create a custom bot greeting function returned when no command is given. # The default behavior of the bot is to return the '/help' command response def greeting(incoming_msg): # Loopkup details about sender sender = bot.teams.people.get(incoming_msg.personId)
# ## MAIN BODY # Retrieve required details from environment variables dotenv.load_dotenv() bot_email = os.getenv('BOT_EMAIL') teams_token = os.getenv('TEAMS_TOKEN') bot_url = os.getenv('BOT_URL') bot_app_name = os.getenv('BOT_APP_NAME') # Create a Bot Object app = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, ) # Add new commands to SparkBot. # Set the bot greeting. app.set_greeting(greeting) app.add_command("/time", "Get Time, Date, and Week information for a Timezone.\nExample: /time EST", current_time) app.add_command("/greeting", "Bot Greeting", greeting) app.add_command("/debug_data", "Debug Data. Examples of accessing Space specific data.", debug_data) app.add_command("/need_comic", "Need some random comic relief", need_comic)
# Retrieve required details from environment variables bot_email = os.getenv("TEAMS_BOT_EMAIL") teams_token = os.getenv("TEAMS_BOT_TOKEN") bot_url = os.getenv("TEAMS_BOT_URL") bot_app_name = os.getenv("TEAMS_BOT_APP_NAME") add_pattern = r".*\/add (\d*)( *)(.+)" # Create a Bot Object bot = TeamsBot(bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, webhook_resource_event=[{ "resource": "messages", "event": "created" }, { "resource": "attachmentActions", "event": "created" }]) # Create a custom bot greeting function returned when no command is given. # The default behavior of the bot is to return the '/help' command response def greeting(incoming_msg): # Lookup details about sender sender = bot.teams.people.get(incoming_msg.personId) # Create a Response object and craft a reply in Markdown. response = Response()
print("TEAMS_BOT_EMAIL") if not teams_token: print("TEAMS_BOT_TOKEN") if not bot_url: print("TEAMS_BOT_URL") if not bot_app_name: print("TEAMS_BOT_APP_NAME") sys.exit() # Create a Bot Object bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, webhook_resource_event=[ {"resource": "messages", "event": "created"}, {"resource": "attachmentActions", "event": "created"}, ], ) def create_message_with_attachment(rid, msgtxt, attachment): headers = { "content-type": "application/json; charset=utf-8", "authorization": "Bearer " + teams_token, } url = "https://api.ciscospark.com/v1/messages" data = {"roomId": rid, "attachments": [attachment], "markdown": msgtxt}
def main(): logging.basicConfig(level=logging.DEBUG) ngrok = ngrokhelper.NgrokHelper(port=5000) bot_url = ngrok.start() logging.debug(f'Bot url: {bot_url}') # Create a new bot bot = TeamsBot(bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True) # Spark API api = webexteamssdk.WebexTeamsAPI(teams_token) logging.debug(f'Bot identity: {api.people.me()}') # for the adaptive card demo we also need a webhook for card actions url = urllib.parse.urljoin(bot_url, 'card_action') name = f'{bot_app_name}_card_action' wh = next((h for h in api.webhooks.list() if h.name == name), None) if wh is None: # create new webhook for card activities api.webhooks.create(name=name, targetUrl=url, resource='attachmentActions', event='created') else: # update existing webhook api.webhooks.update(webhookId=wh.id, name=name, targetUrl=url, resource='attachmentActions', event='created') # register code for that webhook bot.add_url_rule('/card_action', 'card_action', functools.partial(card_action, api), methods=['POST']) # Add new command bot.add_command('/chuck', 'get Chuck Norris joke', get_joke) bot.add_command('/traffic', 'show traffic cams', functools.partial(traffic, api)) bot.add_command('/quote', 'get a random quote', quote) bot.add_command('/number', 'get fun fact for a number', functools.partial(number, api)) bot.add_command('/dilbert', 'get random dilbert comic', functools.partial(dilbert, api)) bot.add_command('/peanuts', 'get random peanuts comic', peanuts) bot.add_command('/card', 'create an adaptive card', functools.partial(card_demo, api)) # run bot bot.run(host='0.0.0.0', port=5000)
def run_demo_health_check(incoming_msg): demo_health_check(incoming_msg.roomId) # Retrieve required details from environment variables bot_email = os.getenv("TEAMS_BOT_EMAIL") teams_token = os.getenv("TEAMS_BOT_TOKEN") bot_url = os.getenv("TEAMS_BOT_URL") bot_app_name = os.getenv("TEAMS_BOT_APP_NAME") # Create a Bot Object # Note: debug mode prints out more details about processing to terminal bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, ) # Setup API required info bot.intersight_base_url = 'https://www.intersight.com/api/v1/' bot.pythonanywhere_username = os.getenv("PYTHONANYWHERE_USER") bot.pythonanywhere_token = os.getenv("PYTHONANYWHERE_API_KEY") bot.path = os.getenv("MERAKISIGHT_PATH") bot.secret_file = os.path.join(bot.path, "SecretKey.txt") bot.intersight_api_key = os.getenv("INTERSIGHT_API_KEY") bot.meraki_api_key = os.getenv("MERAKI_API_KEY") bot.INTERSIGHT_AUTH = IntersightAuth( secret_key_filename=bot.secret_file, api_key_id=bot.intersight_api_key
if not teams_bot_email: print("TEAMS_BOT_EMAIL") if not teams_bot_token: print("TEAMS_BOT_TOKEN") if not teams_bot_url: print("TEAMS_BOT_URL") if not teams_bot_name: print("TEAMS_BOT_APP_NAME") sys.exit() bot = TeamsBot(teams_bot_name, teams_bot_token=teams_bot_token, teams_bot_url=teams_bot_url, teams_bot_email=teams_bot_email, debug=True, webhook_resource_event=[{ "resource": "messages", "event": "created" }, { "resource": "attachmentActions", "event": "created" }]) def close_enough(str1, str2): r = SequenceMatcher(a=str1, b=str2) if r.ratio() > 0.85: return True def greeting(incoming_msg): sender = bot.teams.people.get(incoming_msg.personId)
import json import requests from webexteamsbot import TeamsBot import settings bot = TeamsBot( str(settings.bot_app_name), teams_bot_token=settings.teams_token, teams_bot_url=settings.bot_url, teams_bot_email=settings.bot_email, debug=True, webhook_resource_event=[{"resource": "messages", "event": "created"}, {"resource": "attachmentActions", "event": "created"}] ) def get_attachment_actions(attachment_id): headers = { 'content-type': 'application/json; charset=utf-8', 'authorization': 'Bearer ' + settings.teams_token } url = 'https://api.ciscospark.com/v1/attachment/actions/' + attachment_id response = requests.get(url, headers=headers) _json = response.json() return _json.get('inputs', {})
teams_token = environmentVariables.teams_token bot_url = environmentVariables.bot_url bot_app_name = environmentVariables.bot_app_name uid = environmentVariables.uid session_token = environmentVariables.session_token url_schedule = environmentVariables.url_schedule url_create = environmentVariables.url_create title = "" sDate = "" eDate = "" sfdc = "" # Create a Bot Object bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, ) # Sample greeting function to test the bot def greeting(incoming_msg): sender = bot.teams.people.get(incoming_msg.personId) # Create a Response object and craft a reply in Markdown. response = "Hello {}, I'm a chat bot. ".format(sender.firstName) response += "See what I can do by asking for **/help**." global title print("from hi :" + title)
#mysql statements here query = "SELECT * FROM userdata where id='%s';" % id cursor.execute(query) rows = cursor.fetchall() stringy = "" for row in rows: stringy += str(row) connection.close() return stringy # Create a Bot Object bot = TeamsBot( bot_app_name, teams_bot_token=teams_token, teams_bot_url=bot_url, teams_bot_email=bot_email, debug=True, ) #list of ID's, hardcode moduleDictionary = [ '44654655440', # software '7428202732', # web apps '44347432831' #developer ] #connect id to name moduleNameToId = { '7428202732': 'Web Applications', # web apps '44654655440': 'Software Development', # software '44347432831': 'Developer class' #developer }