コード例 #1
0
ファイル: db.py プロジェクト: sobhe/smsd-server
def handelRecieved(number, text):
    #log data
    log.receivedMessage(number, text)

    if number[-10:] in admins:
        if text.lower() == 'stop':
            return json.dumps({'status': 'stop'})
        elif text.lower() == 'start':
            return json.dumps({'status': 'start'})
        elif text.lower() in ['hello', 'hi', 'hello world', 'salam']:
            sendThis = "Hello Admin"
            add_query = 'INSERT INTO transactions (`to`, `text`) VALUES ("%s", "%s")' % (
                number, sendThis)
            con = createCon()
            con.query(add_query)
            con.commit()
            j = json.dumps({'status': 'ok'})
            return j
    if number[-10:] in rabets or number[-10:] in admins:
        if text.lower() == 'help':
            addHelp(number)
            j = json.dumps({'status': 'ok'})
            return j
        elif text.encode('UTF-8').lower().strip() == u'بله'.encode('UTF-8'):
            if tosend.hasPendingSendToAll(number[-10:]):
                message = tosend.getSendToAll(number[-10:])
                handelRecieved2(number, message)
                tosend.removeSendToAll(number[-10:])
            j = json.dumps({'status': 'ok'})
            return j
        else:
            parts = text.split("\n")
            if parts[0].lower().strip() == 'send to all':
                if parts[1].lower().strip() == 'admins':
                    addForGroup(admins_number, "\n".join(parts[2:]))
                    return json.dumps({'status': 'ok'})
                elif parts[1].lower().strip() == 'rabets':
                    addForGroup(rabets_number, "\n".join(parts[2:]))
                    return json.dumps({'status': 'ok'})
                elif parts[1].lower().strip() == 'tafsir':
                    tosend.addSendToAll(number[-10:], text)
                    addVerify(number, "\n".join(parts[2:]))
                    return json.dumps({'status': 'ok'})
                else:
                    print parts[1].lower().strip()
                    return json.dumps({'status': 'Not OK'})
            else:
                print parts[0].lower().strip()
                return json.dumps({'status': 'Not OK'})
コード例 #2
0
ファイル: db.py プロジェクト: karoon/smsd-server
def handelRecieved(number, text):
    # log data
    log.receivedMessage(number, text)

    if number[-10:] in admins:
        if text.lower() == "stop":
            return json.dumps({"status": "stop"})
        elif text.lower() == "start":
            return json.dumps({"status": "start"})
        elif text.lower() in ["hello", "hi", "hello world", "salam"]:
            sendThis = "Hello Admin"
            add_query = 'INSERT INTO transactions (`to`, `text`) VALUES ("%s", "%s")' % (number, sendThis)
            con = createCon()
            con.query(add_query)
            con.commit()
            j = json.dumps({"status": "ok"})
            return j
    if number[-10:] in rabets or number[-10:] in admins:
        if text.lower() == "help":
            addHelp(number)
            j = json.dumps({"status": "ok"})
            return j
        elif text.encode("UTF-8").lower().strip() == u"بله".encode("UTF-8"):
            if tosend.hasPendingSendToAll(number[-10:]):
                message = tosend.getSendToAll(number[-10:])
                handelRecieved2(number, message)
                tosend.removeSendToAll(number[-10:])
            j = json.dumps({"status": "ok"})
            return j
        else:
            parts = text.split("\n")
            if parts[0].lower().strip() == "send to all":
                if parts[1].lower().strip() == "admins":
                    addForGroup(admins_number, "\n".join(parts[2:]))
                    return json.dumps({"status": "ok"})
                elif parts[1].lower().strip() == "rabets":
                    addForGroup(rabets_number, "\n".join(parts[2:]))
                    return json.dumps({"status": "ok"})
                elif parts[1].lower().strip() == "tafsir":
                    tosend.addSendToAll(number[-10:], text)
                    addVerify(number, "\n".join(parts[2:]))
                    return json.dumps({"status": "ok"})
                else:
                    print parts[1].lower().strip()
                    return json.dumps({"status": "Not OK"})
            else:
                print parts[0].lower().strip()
                return json.dumps({"status": "Not OK"})
コード例 #3
0
ファイル: db.py プロジェクト: karoon/smsd-server
def handelRecieved2(number, text):
    # log data
    log.receivedMessage(number, "[varified]" + text)
    if number[-10:] in rabets or number[-10:] in admins:
        parts = text.split("\n")
        if parts[0].lower().strip() == "send to all":
            if parts[1].lower().strip() == "admins":
                addForGroup(admins_number, "\n".join(parts[2:]))
                return json.dumps({"status": "ok"})
            elif parts[1].lower().strip() == "rabets":
                addForGroup(rabets_number, "\n".join(parts[2:]))
                return json.dumps({"status": "ok"})
            elif parts[1].lower().strip() == "tafsir":
                addForGroup(tafsir, "\n".join(parts[2:]))
                return json.dumps({"status": "ok"})
            else:
                print parts[1].lower().strip()
                return json.dumps({"status": "Not OK"})
        else:
            print parts[0].lower().strip()
            return json.dumps({"status": "Not OK"})
コード例 #4
0
ファイル: db.py プロジェクト: sobhe/smsd-server
def handelRecieved2(number, text):
    #log data
    log.receivedMessage(number, "[varified]" + text)
    if number[-10:] in rabets or number[-10:] in admins:
        parts = text.split("\n")
        if parts[0].lower().strip() == 'send to all':
            if parts[1].lower().strip() == 'admins':
                addForGroup(admins_number, "\n".join(parts[2:]))
                return json.dumps({'status': 'ok'})
            elif parts[1].lower().strip() == 'rabets':
                addForGroup(rabets_number, "\n".join(parts[2:]))
                return json.dumps({'status': 'ok'})
            elif parts[1].lower().strip() == 'tafsir':
                addForGroup(tafsir, "\n".join(parts[2:]))
                return json.dumps({'status': 'ok'})
            else:
                print parts[1].lower().strip()
                return json.dumps({'status': 'Not OK'})
        else:
            print parts[0].lower().strip()
            return json.dumps({'status': 'Not OK'})