Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function processMessage($message)
- {
- $getchat = apiRequestJson("getChat", array(
- 'chat_id' => $message['chat']['id']
- ));
- $getchatadministrator = apiRequestJson("getChatAdministrators", array(
- 'chat_id' => $message['chat']['id']
- ));
- $getchatmember = apiRequestJson("getChatMember", array(
- 'chat_id' => $message['chat']['id'],
- 'user_id' => $message['from']['id']
- ));
- $getchatmemberscount = apiRequestJson("getChatMembersCount", array(
- 'chat_id' => $message['chat']['id']
- ));
- $keepcalm = "Stai calmo";
- //assegno le variabili dalla lettura del json
- //CHAT
- $chat_type = $message['chat']['type'];
- $chat_title = $message["chat"]['title'];
- $chat_id = $message['chat']['id'];
- //GET CHAT MEMBER USER
- $getchatmember_id = $getchatmember['user']['id'];
- $getchatmember_firstname = $getchatmember['user']['first_name'];
- $getchatmember_lastname = $getchatmember['user']['last_name'];
- $getchatmember_username = $getchatmember['user']['username'];
- $getchatmember_status = $getchatmember['status'];
- //GET CHAT
- $getchat_id = $getchat['id'];
- $getchat_firstname = $getchat['first_name'];
- $getchat_lastname = $getchat['last_name'];
- $getchat_username = $getchat['username'];
- $getchat_type = $getchat['type'];
- //GET CHAT ADMINISTRATOR
- $getchatadministrator_id = $getchatadministrator['user']['id'];
- $getchatadministrator_firstname = $getchatadministrator['user']['first_name'];
- $getchatadministrator_username = $getchatadministrator['user']['username'];
- $getchatadministrator_status = $getchatadministrator['status'];
- //FROM
- $from_firstname = $message["from"]['first_name'];
- $from_lastname = $message['from']['last_name'];
- $from_username = $message["from"]['username'];
- $from_id = $message['from']['id'];
- //FORWARD
- $forward_id = $message['forward_from']['id'];
- $forward_firstname = $message['forward_from']['first_name'];
- $forward_lastname = $message['forward_from']['last_name'];
- $forward_username = $message['forward_from']['username'];
- //MESSAGE
- $message_id = $message['message_id'];
- $text = $message['text'];
- //NEW PARTECIPANT
- $newchatmember_id = $message['new_chat_member']['id'];
- $newchatmember_firstname = $message['new_chat_member']['first_name'];
- $newchatmember_username = $message['new_chat_member']['username'];
- //LEFT PARTECIPANT
- $leftchatmember_id = $message['left_chat_member']['id'];
- $leftchatmember_firstname = $message['left_chat_member']['first_name'];
- $leftchatmember_username = $message['left_chat_member']['username'];
- // parametri per la connessione al DB
- include("core/config.php");
- // avvio la connessione al DB
- $conn = mysqli_connect($servernameDB, $usernameDB, $passwordDB, $nameDB);
- //controllo eventuali errori
- if (!$conn) {
- die("Connection failed: " . $conn->connect_error);
- }
- //richiamo le classi per gli RSS
- include("core/rssnews.php");
- //ricerca di user già inseriti o da inserire e notifico se c'è inserimento
- $sqlquery = "SELECT telegram_id FROM g1g1l1n3_users WHERE telegram_id =" . $from_id;
- $result = mysqli_query($conn, $sqlquery);
- if (mysqli_num_rows($result) == 0) {
- $sql = mysqli_query($conn, "INSERT INTO g1g1l1n3_users (firstname, lastname, username, telegram_id, gender, age, language_user, msg_count, state_bot, state_ban, state_bot_super, users_score) VALUES ('$from_firstname','$from_lastname','$from_username','$from_id', '', 0, 'notset', 0, 1, 0, 0, 3)") or die("Query inserimento: " . mysql_error());
- $sqlquerydue = "SELECT telegram_id FROM g1g1l1n3_users";
- $resultdue = mysqli_query($conn, $sqlquerydue);
- echo mysqli_num_rows($resultdue);
- apiRequestJson("sendMessage", array(
- 'chat_id' => "13699180",
- "text" => "L'user " . $from_firstname . " " . $from_lastname . " " . $from_username . " con ID: " . $from_id . " è stato aggiunto al database"
- ));
- }
- //ricerca gruppo inserito o da inserire e notifico se c'è inserimento
- if (strripos($chat_id, "-") !== false) {
- $sqlquery = "SELECT telegram_group_id FROM g1g1l1n3_group WHERE telegram_group_id =" . $chat_id;
- $result = mysqli_query($conn, $sqlquery);
- if (mysqli_num_rows($result) == 0) {
- $sql = mysqli_query($conn, "INSERT INTO g1g1l1n3_group (name_group, telegram_group_id, language_group, state_bot, state_welcome) VALUES ('$chat_title', '$chat_id', '', 1, 1)") or die("Query inserimento: " . mysql_error());
- $sqlquerydue = "SELECT telegram_group_id FROM g1g1l1n3_group";
- $resultdue = mysqli_query($conn, $sqlquerydue);
- echo mysqli_num_rows($resultdue);
- apiRequestJson("sendMessage", array(
- 'chat_id' => "13699180",
- "text" => "Il gruppo " . $chat_title . "con ID: " . $chat_id . " è stato aggiunto al database"
- ));
- } else {
- //non fare nulla
- echo "non ha fatto nulla";
- }
- }
- //seleziono stato del bot gruppo, stato ban gruppo, stato bot generale, stato benvenuto, id del gruppo, lingua gruppo
- $selectGroup = "SELECT * FROM g1g1l1n3_group WHERE $chat_id = telegram_group_id";
- $resultGroup = $conn->query($selectGroup);
- if ($resultGroup->num_rows > 0) {
- // output data of each row
- while ($row = $resultGroup->fetch_assoc()) {
- $printGroupStateBot = $row["state_bot"];
- $printGroupStateBan = $row["state_ban"];
- $printStateBotWelcome = $row["state_welcome"];
- $printTelegramGroupId = $row["telegram_group_id"];
- $printLanguageGroup = $row["language_group"];
- }
- }
- //seleziono stato bot, stato ban users, stato bot generale, lingua users
- $selectGroup = "SELECT * FROM g1g1l1n3_users WHERE $chat_id = telegram_id";
- $resultGroup = $conn->query($selectGroup);
- if ($resultGroup->num_rows > 0) {
- // output data of each row
- while ($row = $resultGroup->fetch_assoc()) {
- $printUsersStateBot = $row["state_bot"];
- $printUsersStateBan = $row["state_ban"];
- $printLanguageUsers = $row["language_user"];
- }
- }
- //seleziono stato bot, stato ban users, stato bot generale, lingua users
- $selectUsernameDB = "SELECT * FROM g1g1l1n3_users WHERE $from_id = telegram_id";
- $resultUsernameDB = $conn->query($selectUsernameDB);
- if ($resultUsernameDB->num_rows > 0) {
- // output data of each row
- while ($row = $resultUsernameDB->fetch_assoc()) {
- $printUsersStateUsername = $row["username"];
- }
- }
- //Carico i settings del bot
- $selectSettingsDB = "SELECT * FROM g1g1l1n3_settings";
- $resultSettingsDB = $conn->query($selectSettingsDB);
- if ($resultSettingsDB->num_rows > 0) {
- // output data of each row
- while ($row = $resultSettingsDB->fetch_assoc()) {
- $printSettingsStateBotSuper = $row["state_bot_super"];
- $printSettingsStateMsgTime = $row["state_msg_time"];
- $printSettingsStateMsgCount = $row["state_msg_count"];
- }
- }
- if ((("$printUsersStateUsername" == "") and ("$from_username" != "")) or ("$printUsersStateUsername" != "$from_username")) {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_users SET firstname = '$from_firstname', lastname = '$from_lastname', username = '$from_username' WHERE telegram_id = $from_id");
- apiRequestJson("sendMessage", array(
- 'chat_id' => "13699180",
- "text" => "L'user " . $from_firstname . " " . $from_lastname . " " . $from_username . " con ID: " . $from_id . " è stato aggiornato"
- ));
- }
- //applico le icone a variabili
- if (($printLanguageGroup == "italian") or ($printLanguageUsers == "italian")) {
- $printIconLanguage = "🇮🇹";
- } else if (($printLanguageGroup == "english") or ($printLanguageUsers == "english")) {
- $printIconLanguage = "🇬🇧";
- }
- //controllo se nel json il testo è presente
- if (isset($message['text'])) {
- check_spam($chat_id, $from_id, $getchatmember_id, $message["date"], $printSettingsStateMsgTime, $printSettingsStateMsgCount);
- //controllo lo stato generale del sistema
- if (($text == "stato sistema") and ($from_id == "13699180")) {
- if ($chat_type == "private") {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "💻 Impostazioni sistema ($chat_id) 💻\n\nlingua : $printIconLanguage\narmatura : $printSettingsStateBotSuper\nstato bot : $printUsersStateBot\n"
- ));
- } else if (($chat_type == "group") or ($chat_type == "supergroup")) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "💻 State System ($chat_id) 💻\n\nlang : $printIconLanguage\nwelcome : $printStateBotWelcome\narmor : $printSettingsStateBotSuper\nstate bot : $printGroupStateBot\nnum msg at second : $printSettingsStateMsgTime\nnum second msg : $printSettingsStateMsgCount"
- ));
- }
- //comando per l'avvio del bot
- } else if (strpos($text, "/start") === 0) {
- if ($chat_id == "-1001062287469") {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "Please respect these rules:\n\n1⃣ Respect all users\n2⃣ No spam and flood.\n3⃣ Is allowed to speak only in English.\n4⃣ Is forbidden sexual content.\n5⃣ If you are bothered by PM, the button: Report Spam button, is your friend.\n6⃣ NOT USE commands of BOT, you can do it in private.\n7⃣ Any user who violates one or more rules will be expelled without notice.\n8⃣ Use our ROM xD."
- ));
- } else if (($printLanguageUsers == "italian") or ($printLanguageGroup == "italian")) {
- goto control;
- } else if (($printLanguageUsers == "english") or ($printLanguageGroup == "english")) {
- goto control;
- } else {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Select language',
- 'reply_markup' => array(
- 'keyboard' => array(
- array(
- '*english*',
- '*italian*'
- )
- ),
- 'one_time_keyboard' => true,
- 'resize_keyboard' => true
- )
- ));
- }
- } else if ($text == '*setspammsg*') {
- if (($chat_type == "group") or ($chat_type == "supergroup")) {
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Seleziona il numero di messaggi massimo',
- 'reply_markup' => array(
- 'keyboard' => array(
- array(
- '*1 msg*',
- '*2 msg*',
- '*3 msg*',
- '*4 msg*',
- '*5 msg*',
- '*6 msg*',
- '*7 msg*',
- '*8 msg*',
- '*9 msg*'
- )
- ),
- 'one_time_keyboard' => true,
- 'resize_keyboard' => true
- )
- ));
- } else {
- }
- } else if ((($text == '*1 msg*') or ($text == '*2 msg*') or ($text == '*3 msg*') or ($text == '*4 msg*') or ($text == '*5 msg*') or ($text == '*6 msg*') or ($text == '*7 msg*') or ($text == '*8 msg*') or ($text == '*9 msg*')) and (($chat_type == "group") or ($chat_type == "supergroup"))) {
- $msgCount = 0;
- $txtWrite = (strpos($text, "$msgCount") === 0);
- for ($msgCount = 0; $msgCount == $txtWrite; ++$msgCount ) {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_settings SET state_msg_count = $msgCount");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Numero messaggi impostato a: '.$msgCount,
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- }
- } else if ($text == '*setspamtime*') {
- if (($chat_type == "group") or ($chat_type == "supergroup")) {
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Seleziona il numero di secondi da analizzare',
- 'reply_markup' => array(
- 'keyboard' => array(
- array(
- '*1 sec*',
- '*2 sec*',
- '*3 sec*'
- )
- ),
- 'one_time_keyboard' => true,
- 'resize_keyboard' => true
- )
- ));
- } else {
- }
- } else if ($text == '*1 sec*') {
- if (($chat_type == "group") or ($chat_type == "supergroup")) {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_settings SET state_msg_time = 1");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Secondi impostati a: 1',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- } else {
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Funzione non disponibile in privato',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- }
- } else if ($text == '*2 sec*') {
- if (($chat_type == "group") or ($chat_type == "supergroup")) {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_settings SET state_msg_time = 2");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Secondi impostati a: 2',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- } else {
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Funzione non disponibile in privato',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- }
- } else if ($text == '*3 sec*') {
- if (($chat_type == "group") or ($chat_type == "supergroup")) {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_settings SET state_msg_time = 3");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Secondi impostati a: 3',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- } else {
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'Funzione non disponibile in privato',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- }
- } else if ($text == '*italian*') {
- if (($chat_type == "group") or ($chat_type == "supergroup")) {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_group SET language_group = 'italian' WHERE telegram_group_id = $chat_id");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'lingua impostata correttamente al gruppo',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- } else if ($chat_type == "private") {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_users SET language_user = 'italian' WHERE telegram_id = $chat_id");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'lingua impostata correttamente',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- } else {
- //non fare nulla
- }
- //rilevo se bisogna applicare la lingua inglese
- } else if ($text == '*english*') {
- if (($chat_type == "group") or ($chat_type == "supergroup")) {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_group SET language_group = 'english' WHERE telegram_group_id = $chat_id");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'language has been set',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- } else if ($chat_type == "private") {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_users SET language_user = 'english' WHERE telegram_id = $chat_id");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'language has been set',
- 'reply_markup' => array(
- 'hide_keyboard' => true
- )
- ));
- } else {
- //non fare nulla
- }
- //rilevo se bisogna applicare l'armatura
- } else if ((strpos($text, "attiva armatura") === 0) and ($from_id == "13699180")) {
- if ($printSettingsStateBotSuper == 1) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "$printSettingsStateBotSuper armatura già attiva"
- ));
- } else {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_settings SET state_bot_super = 1");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "armatura attivata"
- ));
- }
- //rilevo se bisogna disabilitare l'armatura
- } else if ((strpos($text, "test") === 0) and (($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180"))) {
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "$getchatadministrator_id $getchatadministrator_id $getchatadministrator_firstname $getchatadministrator_username $getchatadministrator_status"
- ));
- } else if ((strpos($text, "lascia gruppo") === 0) and ($from_id == "13699180")) {
- apiRequest("leaveChat", array(
- 'chat_id' => $chat_id,
- 'user_id' => $from_id
- ));
- } else if ((strpos($text, "disattiva armatura") === 0) and ($from_id == "13699180")) {
- if ($printSettingsStateBotSuper == 0) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "l'armatura è già disattiva"
- ));
- } else {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_settings SET state_bot_super = 0");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'armatura disattivata'
- ));
- }
- //rilevo se bisogna applicare il messaggio di benvenuto nei gruppi
- } else if ((strpos($text, "attiva benvenuto") === 0) and (($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180"))) {
- if ($printStateBotWelcome == 1) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "benvenuto già attivo"
- ));
- } else {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_group SET state_welcome = 1");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "benvenuto attivato"
- ));
- }
- //rilevo se bisogna applicare il messaggio di benvenuto nei gruppi
- } else if (($text == "disattiva benvenuto") and (($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180"))) {
- if ($printStateBotWelcome == 0) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "benvenuto già diattivo"
- ));
- } else {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_group SET state_welcome = 0");
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequestJson("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => 'benvenuto disattivato'
- ));
- }
- //controllo se il gruppo è stato bannato, se l'users è stato bannato e che lo stato del bot sia attivo
- } else if (($from_id == "13699180") and (strpos($text, "*chat*") === 0)) {
- //seleziono l'ID del gruppo con cui parlare
- $groupToSpoken = explode(" ", $text);
- $groupToSpokenExplode = $groupToSpoken[1];
- $textToSendGroup = explode(" ", $text);
- unset($textToSendGroup[0]);
- unset($textToSendGroup[1]);
- $textToSendGroupToString = implode(" ", $textToSendGroup);
- apiRequest("sendMessage", array(
- 'chat_id' => $groupToSpokenExplode,
- "text" => "$textToSendGroupToString"
- ));
- } else if ((($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180")) and (strpos($text, "penalty") === 0)) {
- $scoreTousers = explode(" ", $text);
- $scoreTousersExplode = $scoreTousers[1];
- //seleziono score info users
- $selectScoreInfo = "SELECT firstname, lastname, username, telegram_id, users_score FROM g1g1l1n3_users WHERE '" . $scoreTousersExplode . "' = telegram_id";
- $resultScoreInfo = $conn->query($selectScoreInfo);
- if ($resultScoreInfo->num_rows > 0) {
- // output data of each row
- while ($row = $resultScoreInfo->fetch_assoc()) {
- $printScoreName = $row["firstname"];
- $printScoreLastname = $row["lastname"];
- $printScoreUsername = $row["username"];
- $printScoreId = $row["telegram_id"];
- $printScoreUsers = $row["users_score"];
- }
- }
- if ($printScoreUsers == "3") {
- if ($printScoreId != "13699180") {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_users SET users_score = 2 WHERE '" . $printScoreId . "' = telegram_id");
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => $printScoreName . " " . $printScoreLastname . " " . $printScoreUsername . " " . $printScoreId . " " . "score: 2"
- ));
- } else {
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "GigilinE is my creator i can't ban it :p"
- ));
- }
- } else if ($printScoreUsers == "2") {
- if ($printScoreId != "13699180") {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_users SET users_score = 1 WHERE '" . $printScoreId . "' = telegram_id");
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => $printScoreName . " " . $printScoreLastname . " " . $printScoreUsername . " " . $printScoreId . " " . "score: 1"
- ));
- } else {
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "GigilinE is my creator i can't ban it :p"
- ));
- }
- } else if ($printScoreUsers == "1") {
- if ($printScoreId != "13699180") {
- $sql = mysqli_query($conn, "UPDATE g1g1l1n3_users SET users_score = 0 WHERE '" . $printScoreId . "' = telegram_id");
- apiRequest("kickChatMember", array(
- 'chat_id' => $chat_id,
- "user_id" => "$printScoreId"
- ));
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "USERS BAN: " . $printScoreName . " " . $printScoreLastname . " " . $printScoreUsername . " " . $printScoreId . " " . "score: 0"
- ));
- } else {
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "GigilinE is my creator i can't ban it :p"
- ));
- }
- }
- } else if ((($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180")) and (strpos($text, "infoname") === 0)) {
- $scoreTousers = explode(" ", $text);
- $scoreTousersExplode = $scoreTousers[1];
- //seleziono score info users
- $selectScoreInfo = "SELECT firstname, lastname, username, telegram_id, users_score FROM g1g1l1n3_users WHERE '" . $scoreTousersExplode . "' = firstname";
- $resultScoreInfo = $conn->query($selectScoreInfo);
- if ($resultScoreInfo->num_rows > 0) {
- // output data of each row
- while ($row = $resultScoreInfo->fetch_assoc()) {
- $printScoreName = $row["firstname"];
- $printScoreLastname = $row["lastname"];
- $printScoreUsername = $row["username"];
- $printScoreId = $row["telegram_id"];
- $printScoreUsers = $row["users_score"];
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => $printScoreName . " " . $printScoreLastname . " " . $printScoreUsername . " " . $printScoreId . " " . "score: " . $printScoreUsers
- ));
- }
- }
- } else if ((($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180")) and (strpos($text, "infolastname") === 0)) {
- $scoreTousers = explode(" ", $text);
- $scoreTousersExplode = $scoreTousers[1];
- //seleziono score info users
- $selectScoreInfo = "SELECT firstname, lastname, username, telegram_id, users_score FROM g1g1l1n3_users WHERE '" . $scoreTousersExplode . "' = lastname";
- $resultScoreInfo = $conn->query($selectScoreInfo);
- if ($resultScoreInfo->num_rows > 0) {
- // output data of each row
- while ($row = $resultScoreInfo->fetch_assoc()) {
- $printScoreName = $row["firstname"];
- $printScoreLastname = $row["lastname"];
- $printScoreUsername = $row["username"];
- $printScoreId = $row["telegram_id"];
- $printScoreUsers = $row["users_score"];
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => $printScoreName . " " . $printScoreLastname . " " . $printScoreUsername . " " . $printScoreId . " " . "score: " . $printScoreUsers
- ));
- }
- }
- } else if ((($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180")) and (strpos($text, "infousername") === 0)) {
- $scoreTousers = explode(" ", $text);
- $scoreTousersExplode = $scoreTousers[1];
- //seleziono score info users
- $selectScoreInfo = "SELECT firstname, lastname, username, telegram_id, users_score FROM g1g1l1n3_users WHERE '" . $scoreTousersExplode . "' = username";
- $resultScoreInfo = $conn->query($selectScoreInfo);
- if ($resultScoreInfo->num_rows > 0) {
- // output data of each row
- while ($row = $resultScoreInfo->fetch_assoc()) {
- $printScoreName = $row["firstname"];
- $printScoreLastname = $row["lastname"];
- $printScoreUsername = $row["username"];
- $printScoreId = $row["telegram_id"];
- $printScoreUsers = $row["users_score"];
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => $printScoreName . " " . $printScoreLastname . " " . $printScoreUsername . " " . $printScoreId . " " . "score: " . $printScoreUsers
- ));
- }
- }
- } else if ((($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180")) and (strpos($text, "*ban*") === 0)) {
- $groupToSpoken = explode(" ", $text);
- $groupToSpokenExplode = $groupToSpoken[1];
- if (strpos($groupToSpokenExplode, "-") === 0) {
- $textToSendGroup = explode(" ", $text);
- unset($textToSendGroup[0]);
- unset($textToSendGroup[1]);
- $textToSendGroupToString = implode(" ", $textToSendGroup);
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "*ban* group_id user_id"
- ));
- apiRequest("kickChatMember", array(
- 'chat_id' => $groupToSpokenExplode,
- "user_id" => "$textToSendGroupToString"
- ));
- } else {
- $textToSendGroup = explode(" ", $text);
- unset($textToSendGroup[0]);
- unset($textToSendGroup[1]);
- $textToSendGroupToString = implode(" ", $textToSendGroup);
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "EXAMPLE: *ban* group_id user_id $groupToSpokenExplode"
- ));
- apiRequest("kickChatMember", array(
- 'chat_id' => $chat_id,
- "user_id" => "$groupToSpokenExplode"
- ));
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "utente bannato"
- ));
- }
- } else if ((($getchatmember_status == "administrator") or ($getchatmember_status == "creator") or ($from_id == "13699180")) and (strpos($text, "*unban*") === 0)) {
- $groupToSpoken = explode(" ", $text);
- $groupToSpokenExplode = $groupToSpoken[1];
- $textToSendGroup = explode(" ", $text);
- unset($textToSendGroup[0]);
- unset($textToSendGroup[1]);
- $textToSendGroupToString = implode(" ", $textToSendGroup);
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "*unban* group_id user_id"
- ));
- apiRequest("unbanChatMember", array(
- 'chat_id' => $groupToSpokenExplode,
- "user_id" => "$textToSendGroupToString"
- ));
- } else if (($from_id == "13699180") and ($text == "*sendupdate*")) {
- apiRequest("sendMessage", array(
- 'chat_id' => "153304151",
- "text" => "Aggiungi GigilinEBot ai tuoi gruppi e rendilo amministratore esso funzionerà da AntiSpam, così eviterai di avere nel tuo gruppo persone che mandano messaggi inutili, tra l'altro con le varie funzioni che ha potresti divertirti con i tuoi amici, scopri i vari comandi avviando il comando /start"
- ));
- } else if (($from_id == "13699180") and ($text == "?aggiungicomando")) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "comando, testo, phrase, general, italian, 1"
- ));
- } else if (($from_id == "13699180") and ($text == "*backup*")) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- function scan_last_inserted($path, $elaps = 86400)
- {
- $ite = new RecursiveDirectoryIterator($path);
- $bytestotal = 0;
- $nbfiles = 0;
- $files = array();
- foreach (new RecursiveIteratorIterator($ite) as $filename => $cur) {
- if (!is_dir($filename)) {
- if (filemtime($filename) >= $elaps) {
- $filesize = $cur->getSize();
- $bytestotal += $filesize;
- $nbfiles++;
- $files[] = "\n" . $filename . "\n";
- }
- }
- }
- $bytestotal = number_format($bytestotal);
- return array(
- 'total_files' => $nbfiles,
- 'files' => $files
- );
- }
- //stampa tempo esecuzione su file
- $file = "core/time.txt";
- $fr = fopen($file, 'r');
- $tempoEsecuzione = fread($fr, 100);
- fclose($fr);
- //fine get
- $backupResult = scan_last_inserted("/home/bwpgkbec/backup/giornaliero", $tempoEsecuzione);
- scan_last_inserted("/home/bwpgkbec/backup/giornaliero");
- $backupResultString = implode(" ", $backupResult['files']);
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "\n\n" . $backupResultString
- ));
- //stampa tempo esecuzione su file
- $oraAttuale = time();
- $file = "core/time.txt";
- $fr = fopen($file, 'w');
- fwrite($fr, $oraAttuale);
- fclose($fr);
- //fine get
- } else if (($from_id == "13699180") and (strpos($text, "*id_group*") === 0)) {
- //seleziono l'ID del gruppo con cui parlare
- $printGroupIdSpokenExplode = explode(" ", $text);
- unset($printGroupIdSpokenExplode[0]);
- $printGroupIdSpokenWithoutCommand = implode(" ", $printGroupIdSpokenExplode);
- $selectGroupIdSpoken = "SELECT telegram_group_id FROM g1g1l1n3_group WHERE '$printGroupIdSpokenWithoutCommand' = name_group";
- $selectGroupIdSpokenResult = $conn->query($selectGroupIdSpoken);
- if ($selectGroupIdSpokenResult->num_rows > 0) {
- // output data of each row
- while ($row = $selectGroupIdSpokenResult->fetch_assoc()) {
- $printGroupIdSpoken = $row["telegram_group_id"];
- }
- }
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "l'id del gruppo è: $printGroupIdSpoken"
- ));
- //apiRequestJson("sendMessage", array ('chat_id' => $chat_id, "text" => 'Seleziona sesso', 'reply_markup' => array ('one_time_keyboard' => true, 'resize_keyboard' => true)));
- //apiRequestJson("sendMessage", array ('chat_id' => $chat_id, "text" => "Inserisci numero", "request_contact" => true));
- // BUTTA FUORI apiRequest("kickChatMember", array('chat_id' => '-1001036318735', "user_id" => "70696777"));
- // RIABILITA UTENTE apiRequest("unbanChatMember", array('chat_id' => '-1001036318735', "user_id" => "70696777"));
- } else
- control:
- if (($printGroupStateBan == 0) and ($printUsersStateBan == 0) and ($printSettingsStateBotSuper == 0)) {
- //variabili per la funzione insulta
- $textToArray = explode(" ", $text);
- $keyInsulta = array_search('insulta', $textToArray);
- $insulta = $keyInsulta + 1;
- //seleziono il comando e lo stato
- $selectTitle = "SELECT title, published FROM g1g1l1n3_phrase WHERE '$text' LIKE concat('%', title, '%') UNION SELECT title, published FROM g1g1l1n3_audio WHERE '$text' LIKE concat('%', title, '%') UNION SELECT title, published FROM g1g1l1n3_images WHERE '$text' LIKE concat('%', title, '%') UNION SELECT title, published FROM g1g1l1n3_link WHERE '$text' LIKE concat('%', title, '%') UNION SELECT title, published FROM g1g1l1n3_rss WHERE '$text' LIKE concat('%', title, '%')";
- $resultTitle = $conn->query($selectTitle);
- $printTitleCount = $resultTitle->num_rows;
- if ($resultTitle->num_rows > 0) {
- // output data of each row
- while ($row = $resultTitle->fetch_assoc()) {
- $printTitle = $row["title"];
- $printPublished = $row["published"];
- }
- }
- //seleziono il campo content italiano con la modalità random
- $selectContent = "SELECT content FROM g1g1l1n3_phrase WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'italian' OR language_addons = 'all') UNION SELECT content FROM g1g1l1n3_audio WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'italian' OR language_addons = 'all') UNION SELECT content FROM g1g1l1n3_images WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'italian' OR language_addons = 'all') UNION SELECT content FROM g1g1l1n3_link WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'italian' OR language_addons = 'all') UNION SELECT content FROM g1g1l1n3_rss WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'italian' OR language_addons = 'all') ORDER BY RAND() ";
- $contentResult = $conn->query($selectContent);
- if ($contentResult->num_rows > 0) {
- // output data of each row
- while ($row = $contentResult->fetch_assoc()) {
- $printContentIt = $row["content"];
- }
- }
- //seleziono il campo content english
- $selectContent = "SELECT content FROM g1g1l1n3_phrase WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'english' OR language_addons = 'all') UNION SELECT content FROM g1g1l1n3_audio WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'english' OR language_addons = 'all') UNION SELECT content FROM g1g1l1n3_images WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'english' OR language_addons = 'all') UNION SELECT content FROM g1g1l1n3_link WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'english' OR language_addons = 'all') UNION SELECT content FROM g1g1l1n3_rss WHERE '$text' LIKE concat('%', title, '%') AND (language_addons = 'english' OR language_addons = 'all') ORDER BY RAND() ";
- $contentResult = $conn->query($selectContent);
- if ($contentResult->num_rows > 0) {
- // output data of each row
- while ($row = $contentResult->fetch_assoc()) {
- $printContentEn = $row["content"];
- }
- }
- //seleziono la directory
- $selectDirectory = "SELECT * FROM g1g1l1n3_audio WHERE '$text' LIKE concat('%', title, '%') UNION SELECT * FROM g1g1l1n3_images WHERE '$text' LIKE concat('%', title, '%') ";
- $resultDirectory = $conn->query($selectDirectory);
- if ($resultDirectory->num_rows > 0) {
- // output data of each row
- while ($row = $resultDirectory->fetch_assoc()) {
- $printDirectory = $row["directory"];
- }
- }
- //seleziono la type_group
- $selectTypeGroup = "SELECT type_group, type_addons FROM g1g1l1n3_phrase WHERE '$text' LIKE concat('%', title, '%') UNION SELECT type_group, type_addons FROM g1g1l1n3_audio WHERE '$text' LIKE concat('%', title, '%') UNION SELECT type_group, type_addons FROM g1g1l1n3_images WHERE '$text' LIKE concat('%', title, '%') UNION SELECT type_group, type_addons FROM g1g1l1n3_link WHERE '$text' LIKE concat('%', title, '%') UNION SELECT type_group, type_addons FROM g1g1l1n3_rss WHERE '$text' LIKE concat('%', title, '%')";
- $resultTypeGroup = $conn->query($selectTypeGroup);
- if ($resultTypeGroup->num_rows > 0) {
- // output data of each row
- while ($row = $resultTypeGroup->fetch_assoc()) {
- $printTypeGroup = $row["type_group"];
- $printTypeAddons = $row["type_addons"];
- }
- }
- //seleziono la sorgente rss
- $selectSourceNews = "SELECT source_news FROM g1g1l1n3_rss WHERE title = '" . $text . "'";
- $resultSourceNews = $conn->query($selectSourceNews);
- if ($resultSourceNews->num_rows > 0) {
- // output data of each row
- while ($row = $resultSourceNews->fetch_assoc()) {
- $printSourceNews = $row["source_news"];
- }
- }
- //seleziono la sorgente
- $selectUsersList = "SELECT firstname, lastname, username, state_ban FROM g1g1l1n3_users";
- $resultUsersList = $conn->query($selectSourceNews);
- if ($resultUsersList->num_rows > 0) {
- // output data of each row
- while ($row = $resultUsersList->fetch_assoc()) {
- $printUsersListName = $row["firstname"];
- $printUsersListFirstname = $row["lastname"];
- $printUsersListUsername = $row["username"];
- }
- }
- //immagini random it
- $directoryRandom = glob($printDirectory . $printContentIt, GLOB_BRACE);
- $randomMultimediaIt = $directoryRandom[array_rand($directoryRandom)];
- //immagini random en
- $directoryRandom = glob($printDirectory . $printContentEn, GLOB_BRACE);
- $randomMultimediaEn = $directoryRandom[array_rand($directoryRandom)];
- //news rss link it
- $feedRssLinkIt = new rss($printContentIt);
- //news rss link en
- $feedRssLinkEn = new rss($printContentEn);
- //variabili aggiuntive
- $textToArray = explode(" ", $text);
- $keyInsulta = array_search('insulta', $textToArray);
- $insulta = $keyInsulta + 1;
- $oraAttuale = date("H:i");
- if (($printLanguageGroup == "italian") or ($printLanguageUsers == "italian")) {
- if (($chat_type == "group") or ($chat_type == "supergroup")) {
- if (strpos($text, "/resume") === 0) {
- include("core/entertainmentcore-it.php");
- } else if ($printGroupStateBot == 1) {
- if ($chat_id == "-4720104") {
- apiRequest("sendMessage", array(
- 'chat_id' => '-104999245',
- "text" => "[$from_firstname|$from_lastname|$from_username|$from_id]\n$text"
- ));
- }
- include("core/entertainmentcore-it.php");
- } else {
- //non eseguo nulla
- }
- } else if ($chat_type == "private") {
- if (strpos($text, "/resume") === 0) {
- include("core/entertainmentcore-it.php");
- } else if (((strpos($text, "*inserisci*") === 0) or (strpos($text, "*esci*") === 0)) and ($printUsersStateBot == 0)) {
- include("core/entertainmentcore-it.php");
- } else if ($printUsersStateBot == 1) {
- if ($chat_id == "13699180") {
- include("core/entertainmentcore-it.php");
- } else {
- apiRequest("sendMessage", array(
- 'chat_id' => '-119335069',
- "text" => "[$from_firstname|$from_lastname|$from_username|$from_id]\n$text"
- ));
- include("core/entertainmentcore-it.php");
- }
- } else {
- //non eseguo nulla
- }
- }
- } else if (($printLanguageGroup == "english") or ($printLanguageUsers == "english")) {
- if ((($chat_type == "group") or ($chat_type == "supergroup")) and ($printGroupStateBan == 0)) {
- if (strpos($text, "/resume") === 0) {
- include("core/entertainmentcore-en.php");
- } else if ($printGroupStateBot == 1) {
- include("core/entertainmentcore-en.php");
- } else {
- //non eseguo nulla
- }
- } else if (($chat_type == "private") and ($printUsersStateBan == 0) and ($printSettingsStateBotSuper == 0)) {
- if (strpos($text, "/resume") === 0) {
- include("core/entertainmentcore-en.php");
- } else if ($printUsersStateBot == 1) {
- apiRequest("sendMessage", array(
- 'chat_id' => '-119335069',
- "text" => "[$from_firstname|$from_lastname|$from_username|$from_id]\n$text"
- ));
- include("core/entertainmentcore-en.php");
- } else {
- //non eseguo nulla
- }
- }
- }
- } else {
- //non fare nulla
- }
- if (($printLanguageUsers == "notset") or ($printLanguageGroup == "notset")) {
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "Send command /start for continue"
- ));
- } else {
- //non fare nulla
- }
- $conn->close();
- } else if ((isset($message['new_chat_member'])) and ($printGroupStateBan == 0) and ($printUsersStateBan == 0) and ($printSettingsStateBotSuper == 0) and ($printStateBotWelcome != 0)) {
- //ricerca di user già inseriti o da inserire
- $sqlquery = "SELECT telegram_id FROM g1g1l1n3_users WHERE telegram_id =" . $newchatmember_id;
- $result = mysqli_query($conn, $sqlquery);
- if (mysqli_num_rows($result) == 0) {
- $sql = mysqli_query($conn, "INSERT INTO g1g1l1n3_users (firstname, lastname, username, telegram_id, gender, age, language_user, msg_count, state_bot, state_ban, users_score) VALUES ('$newchatmember_firstname','$newPartecipantLastName','$newchatmember_username','$newchatmember_id', '', 0, 'notset', 0, 1, 0, 3)") or die("Query inserimento: " . mysql_error());
- $sqlquerydue = "SELECT telegram_id FROM g1g1l1n3_users";
- $resultdue = mysqli_query($conn, $sqlquerydue);
- echo mysqli_num_rows($resultdue);
- }
- //seleziono il nome del gruppo
- $selectNameGroup = "SELECT name_group, telegram_group_id FROM g1g1l1n3_group WHERE $chat_id = telegram_group_id";
- $resultNameGroup = $conn->query($selectNameGroup);
- if ($resultNameGroup->num_rows > 0) {
- // output data of each row
- while ($row = $resultNameGroup->fetch_assoc()) {
- $printNameGroupWelcome = $row["name_group"];
- $printIdGroupWelcome = $row["telegram_group_id"];
- }
- }
- //seleziono il content in base al name
- $selectContentGroup = "SELECT type_group, content FROM g1g1l1n3_phrase WHERE '$printNameGroupWelcome' = type_group";
- $resultContentGroup = $conn->query($selectContentGroup);
- if ($resultContentGroup->num_rows > 0) {
- // output data of each row
- while ($row = $resultContentGroup->fetch_assoc()) {
- $printWelcomeMessage = $row["content"];
- }
- }
- if (($newchatmember_id == "223817217") or ($message['new_chat_participant']['id'] == "223817217")) {
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => "Launch command /start if you want spoken with me :)"
- ));
- } else if ($chat_id == $printIdGroupWelcome) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => $newchatmember_firstname . " |" . $newchatmember_id . "| " . $printWelcomeMessage
- ));
- } else {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => $newchatmember_firstname . " |" . $newchatmember_id . "| " . " welcome to the group, contact @GigilinEBot for other info"
- ));
- }
- $conn->close();
- } else if ((isset($message['left_chat_member'])) and ($printGroupStateBan == 0) and ($printUsersStateBan == 0) and ($printSettingsStateBotSuper == 0) and ($printStateBotWelcome != 0)) {
- apiRequest("sendChatAction", array(
- 'chat_id' => $chat_id,
- 'action' => "typing"
- ));
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- "text" => $leftchatmember_firstname . " we hope to see you again soon"
- ));
- } else {
- //non fare nulla
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement