Esempio n. 1
0
def on_msg_received(msg, matches):
    img = getValidLink(matches.group(1))

    send_message(msg["chat"]["id"], "AE pora ta aki a imag......")
    sent = send_photo(msg["chat"]["id"], img["link"], img["snippet"])

    while sent["ok"] == "false":
        log("sendPhoto retornou false, rentando novamente...")
        img = getValidLink(matches.group(1))
        sent = send_photo(msg["chat"]["id"], img["link"], img["snippet"])
Esempio n. 2
0
def perform_exit():
    log("Parando de acompanhar...")
    socketio.off("scoreboard")
    socketio.off("log")

    socketio.wait(seconds=1)

    opt.clear_log_msg()
    opt.add_log_msg("ae carai to me desligano ta bom tchau")
    opt.update_log()
Esempio n. 3
0
def on_callback_query(msg):
    if started() and msg["message"]["message_id"] == voting.msg_id:
        user = msg["from"]["first_name"]

        if user in voting.going:  # se já está na votação...
            if msg["data"] == '1':  # se estiver confirmando que vai de novo
                log(user + " tentando votar mais de uma vez")
            elif msg[
                    "data"] == '0':  # se estiver pedindo pra ser retirado da lista...
                log("Removendo " + user + " da votação...")
                voting.going.remove(user)
                voting.notgoing.append(user)
        else:
            if msg["data"] == '1':
                log("Adicionando " + user + " à votação...")
                voting.going.append(user)

                if user in voting.notgoing:
                    voting.notgoing.remove(user)

                if voting.number_going() == voting.maxslots:
                    finishVoting(1)

            elif msg["data"] == '0':
                log("Marcando que " + user + " não vai")
                voting.notgoing.append(user)

                if user in voting.going:
                    voting.going.remove(user)

        edit_message_text(voting.chatid,
                          voting.msg_id,
                          voting.generate_str(),
                          reply_markup=MARKUP)
Esempio n. 4
0
    def resend_messages(self):
        if self.log_msg_id != 0:
            api.delete_message(self.chat_id, self.log_msg_id)
            log("reenviando log...")
            self.log_msg_id = api.send_message(
                self.chat_id, self.log_msg,
                parse_mode="")["result"]["message_id"]

        if self.scoreboard_msg_id != 0:
            api.delete_message(self.chat_id, self.scoreboard_msg_id)
            log('reenviando score...')
            self.scoreboard_msg_id = api.send_message(
                self.chat_id, self.scoreboard_msg,
                parse_mode="")["result"]["message_id"]
Esempio n. 5
0
def requestGoogle(query):
    url = "https://www.googleapis.com/customsearch/v1?"
    url = url + "cx=006518944303354753471:um8whdniwke"
    url = url + "&searchType=image"
    url = url + "&key=" + environ["GOOGLEKEY"]

    url = url + "&q=" + query

    response = requests.get(url)
    response = json.loads(response.content)

    index = random.randint(0, len(response["items"]) - 1)

    log("Imagem escolhida: " + response["items"][index]["link"])

    return response["items"][index]
Esempio n. 6
0
def getValidLink(query):
    supportedFormats = ["jpg", "jpeg", "png", "gif"]

    valid = False

    google_img = requestGoogle(query)
    url = google_img["link"]

    while not valid:
        for format in supportedFormats:
            if url[-5:].find(format) != -1:
                valid = True
                break

        if not valid:
            log("Formato inválido, tentando novamente...")
            google_img = requestGoogle(query)
            url = google_img["link"]

    return google_img
Esempio n. 7
0
def finishVoting(reason=0):
    # reason 0: tempo expirado
    # reason 1: todos confirmados
    if started():
        log("Terminando votação...")

        if reason == 0:
            send_message(voting.chatid,
                         "acabando com esta merda de votacao......")
            edit_message_text(voting.chatid, voting.msg_id, "cabo esta merda")
        elif reason == 1:
            send_message(
                voting.chatid,
                "AE CARAI AGR A VAO JOGA TEU" + voting.gamename + ".....")
            edit_message_text(
                voting.chatid, voting.msg_id,
                "cabo a votasao i todos jogo felis para senpre.....\n\nQUEM VAI::::\n"
                + voting.going_as_str())

        started(False)
        voting.reset()
Esempio n. 8
0
def on_msg_received(msg, matches):
    if started():
        send_message(msg["chat"]["id"],
                     "ja ten una votasoao aocntecnedo agro ak porra")
    else:
        log("Iniciando votação pra jogar " + matches.group(1) + "...")
        started(True)
        voting.gamename = matches.group(1)
        voting.maxslots = int(matches.group(2))

        voting.active = True
        voting.chatid = msg["chat"]["id"]
        voting.going.append(msg["from"]["first_name"])

        sent_msg = send_message(msg["chat"]["id"],
                                voting.generate_str(),
                                reply_markup=MARKUP)
        voting.msg_id = sent_msg["result"]["message_id"]

        multimanager = threading.Thread(target=startVoting)
        multimanager.start()
Esempio n. 9
0
def finishVoting(reason=0):
    # reason 0: tempo expirado
    # reason 1: todos confirmados
    if started():
        log("Terminando votação...")

        if reason == 0:
            send_message(voting.chatid, "Finalizando votação.")
            edit_message_text(voting.chatid, voting.msg_id,
                              "Votação encerrada")
        elif reason == 1:
            send_message(
                voting.chatid, "PARABAINS! Decidiram que vão jogar " +
                voting.gamename + ".....")
            edit_message_text(
                voting.chatid, voting.msg_id,
                "Votação encerrada.\n\nOs vacilões que vão jogar:\n" +
                voting.going_as_str())

        started(False)
        voting.reset()
Esempio n. 10
0
def on_callback_query(msg):
    if started() and msg["message"]["message_id"] == voting.msg_id:
        # se já está na votação...
        if msg["from"]["first_name"] in voting.going:
            if msg["data"] == '1':  # se estiver confirmando que vai de novo
                log(msg["from"]["first_name"] +
                    " tentando votar mais de uma vez")
                #send_message(msg["message"]["chat"]["id"], msg["from"]["first_name"] + " vc ja vai porra n floda cacete")
            elif msg[
                    "data"] == '0':  # se estiver pedindo pra ser retirado da lista...
                log("Removendo " + msg["from"]["first_name"] +
                    " da votação...")
                voting.going.remove(msg["from"]["first_name"])
                edit_message_text(voting.chatid,
                                  voting.msg_id,
                                  voting.generate_str(),
                                  reply_markup=MARKUP)
        else:
            if msg["data"] == '1':
                log("Adicionando " + msg["from"]["first_name"] +
                    " à votação...")
                voting.going.append(msg["from"]["first_name"])

                if voting.number_going() == voting.maxslots:
                    finishVoting(1)

                edit_message_text(voting.chatid,
                                  voting.msg_id,
                                  voting.generate_str(),
                                  reply_markup=MARKUP)
Esempio n. 11
0
def on_msg_received(msg, matches):
    chat = msg["chat"]["id"]

    try:
        img = getValidLink(matches.group(1))

        link = img["link"]
        source = img["image"]["contextLink"]
        snippet = img["snippet"]
        caption_text = "[" + snippet + "](" + source + ")"

        send_message(chat, "AE pora ta aki a imag......")
        send_chat_action(chat, "upload_photo")
        sent = send_photo(chat, link, caption_text, msg["message_id"])

        while sent["ok"] == "false":
            log("sendPhoto retornou false, rentando novamente...")
            img = getValidLink(matches.group(1))
            sent = send_photo(chat, link, caption_text)

    except:
        send_message(chat, "pora n axei nd disso ai n.....")