def need_comic(incoming_msg):
    """
    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 = "Clearly its time for some comic relief"

    get_url = 'http://xkcd.com/info.0.json'

    get_response = requests.get(get_url)

    if get_response.status_code != 200:
        response.text = response.text + "\nEven the Comic Relief is tired!"
        raise Exception("Status code: " + str(get_response.status_code) + " for url: " + get_url)

    else:

        #response.files ="https://imgs.xkcd.com/comics/stack.png" 
        data = get_response.json()
        u = str(data["img"])
        response.files = u

    return response
Beispiel #2
0
def listbirthdays(incoming_msg):
    r = requests.get(URL + 'listbirthdays')
    data = json.loads(r.text)
    response = Response()
    response.text = ""
    for x in data.keys():
        response.text = x + " Birthday is  " + data[x][
            0] + " and team members are" + data[x][1] + '\n' + response.text
    return response
Beispiel #3
0
def listholidays(incoming_msg):
    r = requests.get(URL + 'listholidays')
    data = json.loads(r.text)
    response = Response()
    response.text = ""
    sorted_d = dict(
        sorted(data.items(), key=operator.itemgetter(1), reverse=True))
    for x in sorted_d.keys():
        response.text = data[x] + " " + x + '\n' + response.text
    return response
Beispiel #4
0
def capturescreen(incoming_msg):

    response = Response()
    datetime_object = datetime.datetime.now()
    print(datetime_object)
    response.text = "Here is your current Network Health as of " + str(
        datetime_object)

    #im1 = pyautogui.screenshot()
    #im1.save (r"C:\Users\aykorri\OneDrive - Cisco\Desktop\SE Hack\screenshot.png")

    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
Beispiel #5
0
def ret_message(incoming_msg):
    checkregistereduser(incoming_msg.personEmail, incoming_msg.roomId)
    # Create a object to create a reply.
    response = Response()
    response.text = "Happy birthday and have a nice day."
    response.files = "https://thumbs.dreamstime.com/b/happy-birthday-cheerful-colleagues-office-congratulate-vector-full-color-graphics-cute-characters-156278742.jpg"
    # response.files = "https://static.officeholidays.com/images/1280x853c/india-flag-01.jpg"
    return response
Beispiel #6
0
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
Beispiel #7
0
def listhelpdeskemployees(incoming_msg):
    r = requests.get(URL + 'listhelpdeskemployees')
    data = json.loads(r.text)
    response = Response()
    response.text = ""
    for x in data.keys():
        response.text += "Email : " + data[x][0] + " Contact Number:  " + data[
            x][1] + " Name : " + x + '\n'
    return response
Beispiel #8
0
def ret_message(incoming_msg):
    """
    :param incoming_msg:
    :return:
    """
    response = Response()
    response.text = "Here's a fun little meme."

    u = "https://sayingimages.com/wp-content/uploads/"
    u = u + "aaaaaalll-righty-then-alrighty-meme.jpg"
    response.files = u
    return response
Beispiel #9
0
def ret_message(incoming_msg):
    """
    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
Beispiel #10
0
 def test_response_text(self):
     r = Response()
     r.text = "hello"
     self.assertEqual(r.text, "hello")
Beispiel #11
0
 def test_response_as_dict(self):
     r = Response()
     r.text = "foo"
     self.assertIn("text", r.as_dict())
Beispiel #12
0
 def test_response_json(self):
     r = Response()
     r.text = "foo"
     self.assertIn("text", r.json())
Beispiel #13
0
def ping(input):
    response = Response()
    response.text = "pong"
    return response