Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
    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)
bot.add_command("/create", 'Will create a reservation based on your input',
                create_reservation)

if __name__ == "__main__":
    # Run Bots
    bot.run(host="127.0.0.1", port=8080)
Esempio n. 4
0
# 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,
)

# 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, ssl_context="adhoc")

Esempio n. 5
0
bot.add_command(
    "/messageroom",
    "Send your regards to a given email, Example: **/messageroom [email protected]**",
    message_room)
bot.add_command("/searchroom", "Search for the two most recent active room",
                search_room)
bot.add_command(
    "/sendrequest",
    "Send a Yes or No card to a user, Example: **/sendrequest [email protected]**",
    send_request)
bot.add_command("/changeoncallduty", "Change an on call duty date",
                on_call_duty_change_request)
bot.add_command("/listcalendar", "List your calendars", list_calendar)
bot.add_command("/listevents", "List your events of your calendar",
                list_events)
bot.add_command("/createevent", "Create an event on your calendar",
                create_event)
bot.add_command("/updateevent", "Update an event on your calendar",
                update_event)
bot.add_command("/deleteevent", "Delete an event on your calendar",
                delete_event)
bot.add_command(
    "/oncallduty",
    "Get all of today on call duty or a specific one if you add the domain",
    get_on_call_duty)

bot.remove_command("/echo")

if __name__ == "__main__":
    bot.run(host="0.0.0.0", port=80)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 9
0
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)

if __name__ == "__main__":

    logFormatStr = '[%(asctime)s] p%(process)s {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s'
    logging.basicConfig(format = logFormatStr, filename = "./global.log", level=logging.DEBUG)
    formatter = logging.Formatter(logFormatStr,'%m-%d %H:%M:%S')
    fileHandler = logging.FileHandler("./global.log")
    fileHandler.setLevel(logging.DEBUG)
    fileHandler.setFormatter(formatter)
    streamHandler = logging.StreamHandler()
    streamHandler.setLevel(logging.DEBUG)
    streamHandler.setFormatter(formatter)
    app.logger.addHandler(fileHandler)
    app.logger.addHandler(streamHandler)
    app.logger.info("Logging is set up.")

    app.run(host='0.0.0.0')

Esempio n. 10
0
        "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)

if __name__ == "__main__":
    # Run Bot
    bot.run(host="0.0.0.0", port=port)
Esempio n. 11
0
    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)







Esempio n. 12
0
                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)
#bot.add_command("/dosomething", "[Developer function] - returns list of enrolled courses from callgoogle()", do_something)
#bot.add_command("/demo", "[Developer function] - send message with picture attached", picture_message)
#bot.add_command("/pickle", "[Developer function] - delete token.pickle", deletePickle)
#bot.add_command("/checkMods", "[Developer function] - check if dictionaries are populated", getModuleListDict)
#bot.add_command("/oldwork2do", "[Developer function] - check work to do, old function", work2do)
# 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=6969)
    #get_moduleList()
    #get_moduleListAuto();