Ejemplo n.º 1
0
def getAllRecordings(p):
    recordings = ''
    qry = Recording.query(Recording.chat_id > 0)
    for r in qry:
        name = person.getPersonByChatId(r.chat_id).name
        recordings += '/rec_' + str(r.key.id()) + ' - ' + name + ' - ' + str(
            r.date_time.date()) + '\n'
    send_message(
        p.chat_id,
        "ULTIME REGISTRAZIONI:\n\n" + recordings +
        "\nPremi su uno dei link sopra per ascoltare la registrazione corrispondente.",
        kb=[[BOTTONE_INDIETRO]])
Ejemplo n.º 2
0
def getRecentRecordings(p):
    recordings = ''
    qry = Recording.query(
        Recording.approved == recording.REC_APPROVED_STATE_TRUE).order(
            -Recording.date_time).fetch(8)
    for r in qry:
        name = person.getPersonByChatId(r.chat_id).name.encode('utf-8')
        recordings += '/rec_' + str(r.key.id()) + ' - ' + name + ' - ' + str(
            r.date_time.date()) + '\n'
    send_message(
        p.chat_id,
        "ULTIME REGISTRAZIONI:\n\n" + recordings +
        "\nPremi su uno dei link sopra per ascoltare la registrazione corrispondente.",
        kb=[[BOTTONE_INDIETRO]],
        markdown=False)
Ejemplo n.º 3
0
def goToState91(p, **kwargs):
    input = kwargs['input'] if 'input' in kwargs.keys() else None
    giveInstruction = input is None
    if giveInstruction:
        rec = Recording.query(Recording.approved ==
                              recording.REC_APPROVED_STATE_IN_PROGRESS).get()
        if rec:
            p.setLast_recording_file_id(rec.file_id)
            send_voiceLocationTranslation(p, rec, userInfo=True)
            kb = [[BOTTONE_APPROVA, BOTTONE_DISAPPROVA], [BOTTONE_INDIETRO]]
            send_message(p.chat_id, "Approvi questa registrazione?", kb)
        else:
            kb = [[BOTTONE_INDIETRO]]
            send_message(p.chat_id,
                         "Non c'è nessuna registrazione da approvare", kb)
    else:
        if input == '':
            send_message(p.chat_id, "Input non valido.")
        elif input == BOTTONE_APPROVA:
            rec = recording.getRecording(p.last_recording_file_id)
            send_message(rec.chat_id,
                         USER_MSG.format('', str(rec.key.id())),
                         markdown=False)
            send_message(p.chat_id, "Registrazione approvata!")
            rec.approve(recording.REC_APPROVED_STATE_TRUE)
            recording.appendRecordingInGeoJsonStructure(rec)
            sleep(2)
            repeatState(p)
        elif input == BOTTONE_DISAPPROVA:
            rec = recording.getRecording(p.last_recording_file_id)
            send_message(rec.chat_id,
                         USER_MSG.format(' NON ', str(rec.key.id())),
                         markdown=False)
            send_message(
                p.chat_id, "Registrazione NON approvata! "
                "Se vuoi mandare maggiori info scrivi /sendText {0} text".
                format(str(rec.chat_id)))
            rec.approve(recording.REC_APPROVED_STATE_FALSE)
            sleep(2)
            repeatState(p)
        elif input == BOTTONE_INDIETRO:
            redirectToState(p, 9)
        else:
            send_message(
                p.chat_id,
                FROWNING_FACE + " Scusa, non capisco quello che hai detto.")
Ejemplo n.º 4
0
def getLastContibutors(daysAgo):
    dateThreshold = time_util.get_time_days_ago(daysAgo)
    names = set()
    recsCommands = []
    count = 0
    recs = Recording.query(
        Recording.date_time > dateThreshold,
        Recording.approved == recording.REC_APPROVED_STATE_TRUE).fetch()
    for r in recs:
        if r.chat_id <= 0:
            continue
        name = person.getPersonByChatId(r.chat_id).name
        names.add(name)
        recsCommands.append(r.getRecCommand())
        count += 1
    namesString = ', '.join([x.encode('utf-8') for x in names])
    recCommandsString = '\n'.join(['🎙 {}'.format(x) for x in recsCommands])
    return count, namesString, recCommandsString