コード例 #1
0
def decode_msg(msgId):
    uri = 'https://api.ciscospark.com/v1/messages/' + msgId
    resp = Spark.get_message(accessToken, msgId)
    log.info(resp)
    if resp['personId'] != '<put Spark Bot ID in here>':  # Bot ID prevents infinit loop
        log.info("doing somethinsg")
        do_something(resp)
コード例 #2
0
def decode_msg(msgId):
    uri = 'https://api.ciscospark.com/v1/messages/' + msgId
    resp = Spark.get_message(accessToken, msgId)
    log.info(resp)
    if resp['personId'] != 'Y2lzY29zcGFyazovL3VzL1BFT1BMRS8wNWUwOGRlOC0zYjE3LTQyZjQtYjM3Zi1iMzNmMjg4ZWM1OTA':  # Bot ID prevents infinit loop
        log.info("doing something")
        do_something(resp)
コード例 #3
0
def decode_msg(msgId):
    uri = 'https://api.ciscospark.com/v1/messages/' + msgId
    resp = Spark.get_message(accessToken, msgId)
    log.info(resp)
    if resp['personId'] != '<PUT BOT UID HERE (hint: use the ID not the access code)>':  # Bot ID prevents infinit loop
        log.info("doing something")
        do_something(resp)
コード例 #4
0
def decode_msg(msgId):
    uri = 'https://api.ciscospark.com/v1/messages/' + msgId
    resp = Spark.get_message(accessToken, msgId)
    log.info(resp)
    resp['text'] = clean_text(resp['text'])
    if resp['personId'] != '<SPARK BOT ID HERE >':  # Bot ID from /people endpoint prevents infinit loop
        log.info("doing something")
        do_something(resp)
コード例 #5
0
def sparkMsg(roomid, msgid):
    # Get message
    try:
        msg = get_message(app.config['SPARK_ACCESS_TOKEN'], msgid)
        msgtxt = msg.get('text')
    except Exception as e:
        wEvent('sparkMsg', roomid, 'Issue during get message data', 'app', '0',
               e)
        return 'KO'

    # Remove the eventual bot name as first word
    bot_name = app.config['APP_BOT'].split("@")[0]
    msgtxt = msgtxt.split(bot_name, 1)[1]

    # Search request
    if (re.search('^[s|S]earch', msgtxt)):
        return sparkSearch(roomid, msgtxt)

    # Close request
    elif (re.search('^[c|C]lose',
                    msgtxt)) and (msg.get('personEmail')
                                  == app.config['SPARK_USER_STRESS']):
        return sparkClose(roomid)

    # Escalation request
    elif (re.search('^[e|E]scalation', msgtxt)) or (re.search(
            '^[e|E]scalade', msgtxt)):
        return sparkEscalation(roomid, app.config['SPARK_USER_ESCALATION'])

    # Validated by the Stress engineer
    elif (re.search('^[v|V]alid',
                    msgtxt)) and (msg.get('personEmail')
                                  == app.config['SPARK_USER_STRESS']):
        return sparkAddPeople(roomid, app.config['SPARK_USER_DESIGN'])

    # Tips message
    #elif ( msg.get('personEmail') != app.config['APP_BOT']) and (msg.get('personEmail') != app.config['APP_MAIL']):
    #    return sparkPostMsg(roomid, '_Tips_ : ' + random.choice( app.config['SPARK_MSG_TIPS'] ))

    # Record the message
    else:
        wEvent('sparkMsg', roomid, msgtxt, msg.get('personEmail'), '1', msg)

    return 'OK'
コード例 #6
0
ファイル: TechRequest.py プロジェクト: guillain/TechRequest
def message():
    print 'message received'
    jso = json.loads(request.data)
    data = jso.get('data')

    try:
        msg = pyCiscoSpark.get_message(api.config['ACCESS_TOKEN'],
                                       data.get('id'))
    except Exception as e:
        wEvent('message', 'webhook', 'Get Spark message error', 'KO')
        return 'Get Spark message error'

    try:
        exeReq("INSERT INTO sEvents SET sid = '" + data.get('roomId') +
               "', msg = '" + msg.get('text') + "', uid = '0';")
        logstash('bot', msg)
        wEvent('message', 'webhook', 'Messages stored locally', 'OK')
        return 'Message stored locally'
    except Exception as e:
        wEvent('message', 'webhook', 'Database error (put msg data)', 'KO')
        return 'Database error (put msg data)'
コード例 #7
0
#!/usr/bin/python
import pyCiscoSpark
import sys
import config

#storing the Authentication token in a file in the OS vs. leaving in script
accesstoken = config.spark_accesstoken

#grabbing messageId from the command line argument from ciscospark.php
msgid = str(sys.argv[1])

#reading text from message that caused alert
txt = pyCiscoSpark.get_message(accesstoken, msgid)
print txt['text']
#return