Пример #1
0
        $exists = $db->getRow(sprintf("SELECT 1 FROM {$db->getTable('spotter')} " . "WHERE spotter_chat_ID = '%d'", $message['chat']['id']));
        // Insert if not exists
        $exists || $db->insertRow('spotter', [new DBCol('spotter_chat_id', $message['chat']['id'], 'd'), new DBCol('spotter_datetime', 'NOW()', '-')]);
        apiRequest('sendMessage', ['chat_id' => $message['chat']['id'], 'text' => _("Ecco... /ciclo, /mamma o /spotted?")]);
    } elseif (is_command($text, '/ciclo')) {
        apiRequest('sendMessage', ['chat_id' => $message['chat']['id'], 'text' => _("Non ho cicli mestruali. Screanzato!")]);
    } elseif (is_command($text, '/mamma')) {
        apiRequest('sendMessage', ['chat_id' => $message['chat']['id'], 'text' => _("TUA MADRE?")]);
    } elseif (is_command($text, '/spotted')) {
        $spotted = ltrim(str_replace('/spotted', '', $text));
        if (strlen($spotted) === 0) {
            apiRequest('sendMessage', ['chat_id' => $message['chat']['id'], 'text' => _("Questo comando serve a mandare messaggi accazzo.\n Esempio:\n\n/spotted Dio Cane!")]);
        } else {
            $spotted = str_truncate($spotted, 300, '...');
            $db->insertRow('spotted', [new DBCol('spotted_datetime', 'NOW()', '-'), new DBCol('spotted_message', $spotted, 's'), new DBCol('spotted_chat_id', $message['chat']['id'], 'd')]);
            $spotted_ID = $db->getLastInsertedID();
            $spotters = $db->getResults("SELECT spotter_ID FROM {$db->getTable('spotter')}", 'Spotter');
            $fifo_rows = [];
            foreach ($spotters as $spotter) {
                $fifo_rows[] = [$spotted_ID, $spotter->spotter_ID];
            }
            $db->insert('fifo', ['spotted_ID' => 'd', 'spotter_ID' => 'd'], $fifo_rows);
            apiRequest('sendMessage', ['chat_id' => $message['chat']['id'], 'text' => sprintf(_("Sta roba sta per esser mandata a *%d* persone:\n- «%s»\n\nA me pare na gran cazzata... Però sarà fatto fra pochi istanti."), count($spotters), $spotted), 'parse_mode' => 'markdown']);
        }
    } else {
        apiRequest('sendMessage', ['chat_id' => $message['chat']['id'], 'text' => _("Porcoddio quanta ignoranza a non saper usare un bottino.. Quali cazzo di problemi hai? Sei un aborto.")]);
    }
}
// At the end... Try sending some messages...
spotted_fifo(4);
Пример #2
0
            $fifo_rows = [];
            foreach ($spotters as $spotter) {
                $fifo_rows[] = [$spotted_ID, $spotter->spotter_ID];
            }
            insert_values('fifo', ['spotted_ID' => 'd', 'spotter_ID' => 'd'], $fifo_rows);
        }
        refresh_admin_keyboard($update['message']['chat']['id'], "Messaggio pubblicato");
    } elseif (is_command($text, 'Elimina')) {
        $spotted_ID = (int) trim(str_replace("Elimina", '', $text));
        $spotted_ID && query(sprintf("DELETE FROM {$T('spotted')} WHERE spotted_ID = %d", $spotted_ID));
        refresh_admin_keyboard($update['message']['chat']['id'], "Messaggio eliminato");
    } elseif (is_command($text, '/help')) {
        $text = ltrim(str_replace('/help', '', $text));
        if (strlen($text) === 0) {
            apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => _("Per inviare un messaggio ai programmatori, scrivi <code>/help messaggio</code>.\n" . "(Es. /help Salve, non riesco a mandare uno spot perche'...)"), 'parse_mode' => 'HTML']);
        } else {
            apiRequest('sendMessage', ['chat_id' => WANZO, 'text' => _("E' stato richiesto un help con messaggio: " . $text . "\nDa: " . $first_name . " " . $last_name . " @" . $username . " " . $chat_id), 'parse_mode' => 'HTML']);
        }
    } elseif (is_command($text, '/messaggio')) {
        $text = ltrim(str_replace('/messaggio', '', $text));
        $text = explode('->', $text);
        $messaggio = $text[1];
        $chat_id = $text[0];
        apiRequest('sendMessage', ['chat_id' => $chat_id, 'text' => _("- <b>Messaggio dal team di SpottedUnito</b> -\n\n" . $messaggio), 'parse_mode' => "HTML"]);
    } else {
        apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => _("Nessun comando disponibile con le parole <code>{$text}</code>. Digita o clicca su /start per rivedere le istruzioni."), 'parse_mode' => "HTML"]);
    }
}
// At the end... Try sending some messages...
spotted_fifo(3);
Пример #3
0
<?php

/*
 * Spotted (UniTo?)
 * Copyright (C) 2015 Wanzo Laviola, Valerio Bozzolan
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
// This page is usually visited by a cron job
require 'load.php';
HTTP_json_header();
echo json_encode(['sent' => spotted_fifo(15)]);