コード例 #1
0
    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)
コード例 #2
0
    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()
コード例 #3
0
ファイル: demobot.py プロジェクト: erikthiele/duwebhook
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)
コード例 #4
0
    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()
コード例 #5
0
#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:
        schedule.run_pending()
        time.sleep(1)
コード例 #6
0
MAIN
"""

if __name__ == "__main__":
    # MQTT connection parameters
    client.on_connect = on_connect
    client.on_disconnect = on_disconnect
    client.on_message = on_message
    client.on_log = on_log
    client.on_publish = on_publish

    # Topics to subscribe
    client.subscribe("eschbornoffice/things/{}/uplink".format(parkEUI1))
    client.subscribe("eschbornoffice/things/{}/uplink".format(parkEUI2))
    client.subscribe("eschbornoffice/things/{}/uplink".format(parkEUI3))
    client.subscribe("eschbornoffice/things/{}/uplink".format(parkEUI4))

    #Initaliaze Memcached
    init_memcache_parkingstatus()

    # Bot commands
    bot.set_help_message("Hi! I will automatically notify you if one parking space is still available or all are occupied. You can also ask me, see commands below. More information: https://fkf3parking.devnetcloud.com:\n")
    bot.remove_command("/echo")
    bot.add_command("/c", "Get the current parking status", getc)
    #bot.add_command("/r", "Remove the bot from the current room", removebot)
    bot.add_new_url("/wc", "website-current", wc)

    # Start MQTT client and run bot
    client.loop_start()
    bot.run(host="0.0.0.0", port=999)
コード例 #7
0
    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("/planets", "List the planets.", planets)
    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)
コード例 #8
0
            return "User {} removed from approved users list.".format(user_email)
        else:
            return "User not found in approved users list."
    else:
        return "No user provided."


# Create help message for current_time command
current_time_help = "Look up the current time for a given timezone. "
current_time_help += "_Example: **/time EST**_"

# Set the bot greeting.
bot.set_greeting(greeting)

# Add new commands to the bot.
bot.add_command("attachmentActions", "*", handle_cards)
bot.add_command("/showcard", "show an adaptive card", show_card)
bot.add_command("/dosomething", "help for do something", do_something)
bot.add_command(
    "/demo", "Sample that creates a Teams message to be returned.", ret_message
)
bot.add_command("/time", current_time_help, current_time)

# Add new admin commands to the bot.
bot.add_admin_command(
    "/approve_user", "Add user email address to bot approved users list", approve_user
)
bot.add_admin_command(
    "/remove_user",
    "Remove user email address from bot approved users list",
    remove_user,
コード例 #9
0
    path = (
        r"C:\Users\aykorri\OneDrive - Cisco\Desktop\SE Hack\screenshot.png")
    #titles = pygetwindow.getAllTitles()

    #x1, y1, width, height = pygetwindow.getWindowGeometry('How to screenshot a specific window using Python')
    #x2 = x1 + width
    #y2 = y1 + height

    #pyautogui.screenshot(path)

    #im = Image.open(path)
    #im = im.crop((x1, y1, x2, y2))
    #im.save(path)
    #im.show(path)

    u = r"C:\Users\aykorri\OneDrive - Cisco\Desktop\SE Hack\screenshot.png"
    response.files = u
    return response


bot.set_greeting(botgreeting)

bot.add_command(
    "/capture dashboard",
    "Takes a screenshot from your Grafana dashboard to be returned",
    capturescreen)

if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #10
0

# 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),
                 incoming_msg.text,
                 font=IMAGE_FONT,
                 fill=('black'))
    drawing.rectangle([(0, 0), (200, 200)],
                      fill=None,
                      outline='black',
                      width=2)
    img.save('/app/' + image_filename)
    return "image saved as: " + image_filename


# Add new commands to the box.
bot.add_command("/createimage", "help for create image", create_image)

if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #11
0
    Sample function that uses a Response object for more options.
    :param incoming_msg: The incoming message object from Teams
    :return: A Response object based reply
    """
    # Create a object to create a reply.
    response = Response()

    # Set the text of the reply.
    response.text = "Here's a fun little meme."

    # Craft a URL for a file to attach to message
    u = "https://sayingimages.com/wp-content/uploads/"
    u = u + "aaaaaalll-righty-then-alrighty-meme.jpg"
    response.files = u
    return response


# Set the bot greeting.
bot.set_greeting(greeting)

# Add new commands to the bot.
bot.add_command('attachmentActions', '*', handle_cards)
bot.add_command("/operations", "Show Cloud Operations", show_operations_card)

# Every bot includes a default "/echo" command.  You can remove it, or any
# other command with the remove_command(command) method.
bot.remove_command("/echo")

if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #12
0
ファイル: MrRobot.py プロジェクト: tmestery/mrrobot
    """
    list = [
        "Yes, most definitely!", "The chances are high!", "Not likely!",
        "May the odds be ever in your favor.", "You got no shot, kid.",
        "Try it out and see!", "23% of working", "99.9% success rate",
        "Congratulations, yes!", "Ask a probably question,"
        "Ask again later", "Better not tell you now", "Cannot predict now",
        "Concentrate and ask again", "Don't count on it"
    ]

    X = ("Your Response Is: ")
    return X + random.choice(list)


# Add new commands to the box.
bot.add_command("/dosomething", "Help, for do something.", do_something)
bot.add_command("/TheOffice", "Post a meme from The Office.", TheOffice)
bot.add_command("/Brooklyn99", "Post meme from Brooklyn99.", Brooklyn99)
bot.add_command("/ParksAndRecreation",
                "Post a meme from Parks, and Recreation.", ParksAndRecreation)
bot.add_command("/MrRobot", "Post a meme from Mr.Robot.", MrRobot)
bot.add_command("/SchittsCreek", "Post a meme from Schittscreek.",
                SchittsCreek)
bot.add_command("/Brawlstars", "Post a meme from brawlstars.", Brawlstars)
bot.add_command("/Coding", "Post memes about coding.", Coding)
bot.add_command("/Magic8Ball", "Post a random Magic 8 Ball response.",
                Magic8Ball)
bot.add_command("/Harden", "Post a meme of James Harden", Harden)
bot.add_command("/GreysAnatomy", "Post a meme of Greys Anatomy.", GreysAnatomy)
bot.add_command("/Music", "Post a meme of music.", Music)
コード例 #13
0
                lunchtime[time]=[person["user"]]
    answer = ""
    for item in lunchtime :
        if len(lunchtime[item])>1:
            user = "******".join(lunchtime[item])
            answer += "{} want to eat at {}h{} \n".format(user,item[0:2],item[2:])
        else:
            user = lunchtime[item][0]
            answer += "{} wants to eat at {}h{} \n".format(user,item[0:2],item[2:])
      
    Lunch = Query()
    result = db.search((Lunch.date==str(datetime.now().timetuple().tm_yday)) & (Lunch.userAction=='no'))
    
    return answer

bot.add_command('attachmentActions','*',attachment)

bot.add_command ("eat",'I will organise lunch',eat)
bot.add_command ('/hello','hello world',hello)
bot.add_command ('who','users eat', who)



bot.run(host='0.0.0.0',port=6000,debug=True)






コード例 #14
0
    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)
コード例 #15
0
ファイル: webexBot.py プロジェクト: aswath160598/Ciscobot
def memberadded(api, incoming_msg):
    print(incoming_msg)
    response = Response()

    # Set the text of the reply.
    response.text = "Hi " + (
        (incoming_msg['data'])['personDisplayName']
    ) + ". On behalf of all of us, welcome onboard! We believe you will be a terrific asset to our team, and we look forward to your input! We are so excited about having you on our team!"
    return response


# Set the bot greeting.
bot.set_greeting(greeting)

# Add new commands to the bot.
bot.add_command("/demo", "Sample that creates a Teams message to be returned.",
                ret_message)
bot.add_command('memberships', '*', memberadded)
bot.add_command("/floaters", "List floaters .", listfloaters)
bot.add_command("/listbirthdays", "List Birthdays .", listbirthdays)
bot.add_command("/holidays", "List Holidays .", listholidays)
bot.add_command("/helpdesk", "List HelpDeskEMployees .", listhelpdeskemployees)
# Every bot includes a default "/echo" command.  You can remove it, or any other command with the remove_command(command) method.
bot.remove_command("/echo")
bot.remove_command("/help")

if __name__ == "__main__":
    load_allowedusers()
    load_registeredusers()
    bot.run(host="0.0.0.0", port=5000)
コード例 #16
0
    cur_date = returned_data[0]
    cur_time = returned_data[1][:5]
    timezone_name = r["timeZoneName"]

    # Craft a reply string.
    reply = "In {TZ} it is currently {TIME} on {DATE}.".format(
        TZ=timezone_name, TIME=cur_time, DATE=cur_date)
    return reply


# Create help message for current_time command
current_time_help = "Look up the current time for a given timezone. "
current_time_help += "_Example: **/time EST**_"

# Set the bot greeting.
bot.set_greeting(greeting)

# Add new commands to the box.
bot.add_command("/dosomething", "help for do something", do_something)
bot.add_command("/demo", "Sample that creates a Teams message to be returned.",
                ret_message)
bot.add_command("/time", current_time_help, current_time)

# Every bot includes a default "/echo" command.  You can remove it, or any
# other command with the remove_command(command) method.
bot.remove_command("/echo")

if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #17
0
    data = {"roomId": rid, "attachments": [attachment], "markdown": msgtxt}
    response = requests.post(url, json=data, headers=headers)
    return response.json()


def get_attachment_actions(attachmentid):
    headers = {
        'content-type': 'application/json; charset=utf-8',
        'authorization': 'Bearer ' + teams_token
    }

    url = 'https://api.ciscospark.com/v1/attachment/actions/' + attachmentid
    response = requests.get(url, headers=headers)
    return response.json()


# Set the bot greeting.
bot.set_greeting(greeting)

# Add new commands to the bot.
bot.add_command('attachmentActions', '*', handle_cards)
bot.add_command("/meeting", "Schedule a Meeting", show_calendar_meeting_card)
bot.add_command("/note", "Create a Shared OneNote", show_onenote_card)

# Every bot includes a default "/echo" command.  You can remove it, or any
# other command with the remove_command(command) method.
bot.remove_command("/echo")

if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #18
0
    # Create and Return the message
    response.markdown = """
    {}
    """.format(interface)
    return response


# Create help message for interface-config command
interface_config_help = "Retrieve the configuration for an interface. "
interface_config_help += "_Example: **/interface-config Ethernet1/1**_"

# Set the bot greeting.
bot.set_greeting(greeting)

# Add new commands to the box.
bot.add_command("/crc", "See if any interfaces have CRC Errors.",
                check_crc_errors)
bot.add_command("/vlanlist", "See what VLANs I have configured.", vlan_list)
bot.add_command("/vlan-interfaces", vlan_interfaces_help, vlan_interfaces)
bot.add_command("/arplist", "See what ARP entries I have in my table.",
                arp_list)
bot.add_command("/interface-config", interface_config_help,
                netmiko_interface_details)

# Every bot includes a default "/echo" command.  You can remove it, or any
# other command with the remove_command(command) method.
bot.remove_command("/echo")

if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #19
0
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)

app.add_command("/aci_health", "Check Overall Health of the DevNet Always On APIC", aci_health)

app.add_command("/aci_faults", "List top 15 Faults on DevNet Always On APIC", aci_faults)

app.add_command("/l3_sum", "Show Routable Interfaces on device", l3_sum)

app.add_command("/l3_report", "Device Routable Interfaces Report", l3_report)
コード例 #20
0
        + incoming_msg.personId + "';", conn)
    export_excel = df.to_excel(
        '/home/toobradsosad/enablement-buddy/exports/activities.xlsx',
        index=None,
        header=True)  #Don't forget to add '.xlsx' at the end of the path
    # export_csv = df.to_csv('/home/toobradsosad/enablement-buddy/exports/temp.csv', index = None, header=True) #Don't forget to add '.csv' at the end of the path
    num_enablements = df.shape[0]
    response = Response()
    response.markdown = "You've logged **" + str(
        num_enablements) + "** activities! Here's a report for your records."
    response.files = "/home/toobradsosad/enablement-buddy/exports/activities.xlsx"
    return response


# Set the bot greeting.
bot.set_greeting(greeting)

# Add commands to the bot.
bot.add_command('attachmentActions', '*', handle_cards)
bot.add_command(
    "/add",
    "Add a new enablement (/add <description> OR /add <# recipients> <description>)",
    add_enablement)
bot.add_command("/card", "Log an activity using a card!", show_card)
bot.add_command("/report", "Get a report of your activities to-date.",
                generate_report)
bot.remove_command("/echo")

if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #21
0
ファイル: demobot.py プロジェクト: jeokrohn/duwebhook
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)
コード例 #22
0
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
)

bot.frequency = {}
bot.prev_percents = {}

# Set the bot greeting.
bot.set_greeting(greeting)

# Add new commands to the box.
bot.add_command("/changefrequency", "Set the frequency (**hourly** or **daily**) for Merakisight reporting", change_monitoring_frequency)
bot.add_command("/startmonitoring", "Tell Merakisight to start monitoring at the configured interval", start_monitoring)
bot.add_command("/stopmonitoring", "Tell Merakisight to stop monitoring", stop_monitoring)
bot.add_command("/healthcheck", "Run a health check right now", run_demo_health_check)

# Every bot includes a default "/echo" command.  You can remove it, or any
# other command with the remove_command(command) method.
bot.remove_command("/echo")


if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #23
0
ファイル: teamsbot.py プロジェクト: vbonassies/webexTeamsBot
    returned_data = r["currentDateTime"].split("T")
    cur_date = returned_data[0]
    cur_time = returned_data[1][:5]
    timezone_name = r["timeZoneName"]

    reply = "In {TZ} it is currently {TIME} on {DATE}.".format(
        TZ=timezone_name, TIME=cur_time, DATE=cur_date)
    return reply


current_time_help = "Look up the current time for a given timezone. "
current_time_help += "_Example: **/time GMT**_"

bot.set_greeting(greeting)

bot.add_command('attachmentActions', '*', handle_cards)
bot.add_command("/getmyinfos", "Get your infos", get_my_infos)
bot.add_command("/getemail",
                "Get email of user from his displayName **NOT WORKING ATM**",
                get_email_from_display_name)
bot.add_command("/showcard", "Show an adaptive card", show_card)
bot.add_command("/showlistcard", "Show an adaptive card with input_choice",
                show_list_card)
bot.add_command("/dosomething", "Help for do something", do_something)
bot.add_command("/demo", "Sample that creates a Team message to be returned.",
                ret_message)
bot.add_command("/quickmaths",
                "Do some quick maths. Example: **/quickmaths 1+1**",
                quickmaths)
bot.add_command("/time", current_time_help, current_time)
bot.add_command("/questions", "List of the questions I can answer", questions)
コード例 #24
0
        '''
    config_dict = xmltodict.parse(config)

    # most basic differentiation of the user's command.
    if incoming_msg.text == "/changeint4 enable":
        netconf_reply = m.edit_config(target='running', config=config)
        return "Int4 was successfully enabled."
    elif incoming_msg.text == "/changeint4 disable":
        config_dict["config"]["interfaces"]["interface"]["enabled"] = "false"
        config = xmltodict.unparse(config_dict)
        netconf_reply = m.edit_config(target='running', config=config)
        return "Int4 was successfully disabled."
    else:
        return "Wrong command, please try again."


if __name__ == "__main__":
    # Add new commands to the box.
    bot.add_command("/getinfo", "Get basic device information", getinfo)
    bot.add_command("/getallinterfaces", "Get information from all interfaces",
                    getallinterfaces)
    bot.add_command("/changeint4",
                    "disable or enable Interface 4: e.g. /changeint4 disable",
                    change_interface4)
    bot.remove_command("/echo")
    bot.set_help_message(
        "Welcome to the IoT Config Bot! You can use the following commands:\n")

    # Run Bot
    bot.run(host="0.0.0.0", port=5000)
コード例 #25
0
    headers = {
        'Content-Type': "application/json",
        'X-Booked-SessionToken': session_token,
        'X-Booked-UserId': uid,
        'cache-control': "no-cache",
    }

    response = requests.request("POST", url, json=payload, headers=headers)
    print(response.text)

    return "Reservation created ! You'll receive a confirmation mail shortly, now please fill in the briefing document by following this link : http://ixc.cisco.com/ixc/form/ixc-briefing , see you @ IXC ! :) "


# Bot commands :)

bot.add_command("/hi", "I say Hi", greeting)
bot.add_command("/reservations", 'Shows IXC reservation (Not implemented)',
                get_reservations)
bot.add_command("/title", 'Start your IXC reservation with a title', giveTitle)
bot.add_command(
    "/start",
    'After entering the title, enter a start date please for your booking',
    startDate)
bot.add_command(
    "/end",
    'After entering the start date, enter a end date please for your booking',
    endDate)
bot.add_command(
    "/sfdc",
    'After entering a start and end date, please enter a VALID sfdc deal ID',
    sfdc)
コード例 #26
0
        return "Token.pickle has been removed"
    else:
        return "token.pickle failed to remove"


# Create help message for current_time command
current_time_help = "Look up the current time for a given timezone. "
current_time_help += "_Example: **/time EST**_"

# Set the bot greeting.
bot.set_greeting(greeting)

# Add new commands to the box.

# uncommenting for presentation bot.add_command("/time", current_time_help, current_time)
bot.add_command("/updates", "[Working] Gets any updates made to existing work",
                updateStudents)
bot.add_command("/announcements",
                "[Working] Gets announcements from all courses",
                announcements_test)
bot.add_command("/work2do",
                "[Working] Gets outstanding work, organizable by time",
                work2do2)
bot.add_command(
    "/worklist",
    "[Working] Gets your outstanding work to do from all courses [new func]",
    work2doALL)
bot.add_command("/get_modlist",
                "[Working] Get list of enrolled courses (args: -dev)",
                get_moduleList)

#bot.add_command("/db", "[Developer function] - Test connection to database with calldb()", callldb)