Основной сайт хуманэмулятор.рф | Демо | Купить | API | Wiki
Web / telegram
repost_message
repost_message($from_chat_id,$message_id,$to_chat_id,$is_forward=true); - Выполнить пересылку сообщения из одного чата в другойФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Demonstrates how to repost Telegram messages $xhe_host = getenv("RPABOT_HOST_URL"); if (!isset($path)) { // Path to the init.php file for connecting to the XHE API $path = "../../../Templates/init.php"; // Including init.php grants access to all classes and functionality for working with the XHE API require($path); } // beginning echo "\n<font color=blue>telegram->repost_message</font>\n"; // get from: https://core.telegram.org/api $appID = "xxx"; $appHash = "xxx"; $myPhoneNumber = "+7xxx"; $password = "xxx!"; // step 1 echo ("1. Connect to telegram: "); echo (WEB::$telegram->connect($appID, $appHash)); // step 2 echo ("\n2. Request authorization: "); $res = WEB::$telegram->request_authorization($myPhoneNumber); echo ($res); if ($res != "connected") { // verification code input if ($res == "verification_code") { $auth_code = WINDOW::$app->get_dlg_input_string("dlg_1", "Enter authorization code from SMS or chat:"); // step 3 echo ("\n3. Authorize: "); $res = WEB::$telegram->authorization($myPhoneNumber, $res, $auth_code); echo ($res); } // password input if ($res == "password") { $auth_code = WINDOW::$app->get_dlg_input_string("dlg_1", "Enter password:"); // step 3 echo ("\n3. Authorize: "); $res = WEB::$telegram->authorization($myPhoneNumber, $res, $password); echo ($res); } if ($res != "ok") { echo ("\n4. Authorization failed: "); WINDOW::$app->quit(); } } // step 5 echo ("\n5. Get channels: "); $channels = WEB::$telegram->get_chats("chanel"); echo (count($channels)); // step 6 $from_index = 13; $from_id = $channels[$from_index]->id; $from_title = $channels[$from_index]->title; $messages = WEB::$telegram->get_chat_messages($from_id); $last_message_id = $messages[count($messages) - 1]->ID; $to_index = 20; $to_id = $channels[$to_index]->id; $to_title = $channels[$to_index]->title; // Example 1 echo ("\n6. Repost last message from $from_title to $to_title: "); $repost_result = WEB::$telegram->repost_message($from_id, $last_message_id, $to_id); echo ($repost_result); // step 7 echo ("\n7. Disconnect: "); echo (WEB::$telegram->disconnect()); // end echo "\n"; // Quit WINDOW::$app->quit();
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7040" from xweb_human_emulator import * # начало echo("<hr><font color=blue>seo.xxxxxxxxx</font><hr>") # получить можно тут : https://core.telegram.org/api appID = "xxx"; appHash = "xxx"; myPhoneNumber="+7xxx"; password="xxx" # 1 шаг echo("1. Соединится с телеграм : "); echo(telegram.connect(appID, appHash)); # 2 шаг echo("\n2. Запросить авторизацию : "); res = telegram.request_authorization(myPhoneNumber); echo(res); if res!="connected": # ввод кода верификации if res=="verification_code": auth_code=app.get_dlg_input_string("dlg_1","Введите код авторизации из смс или чата:"); # 3 шаг echo("\n3. Авторизоваться : "); res = telegram.authorization(myPhoneNumber,res,auth_code); echo(res); # ввод пароля if res=="password": auth_code=app.get_dlg_input_string("dlg_1","Введите пароль:"); # 3 шаг echo("\n3. Авторизоваться : "); res = telegram.authorization(myPhoneNumber,res,password); echo(res); if res!="ok": echo("\n4. Не удалось авторизоваться : "); app.quit(); # 5 шаг echo("\n5. Получить каналы : "); chanels = telegram.get_chats("chanel"); echo(len(chanels)); # 6 шаг from_index=13; from_id =chanels[from_index]["id"]; from_title=chanels[from_index]["title"]; messages = telegram.get_chat_messages(from_id); last_message_id = messages[len(messages)-1]["ID"]; to_index=20; to_id =chanels[to_index]["id"]; to_title=chanels[to_index]["title"]; # 6 шаг echo("\n6. Репостнуть последнее сообщение из "+from_title+" в "+to_title+": "); echo(telegram.repost_message(from_id,last_message_id,to_id)); # 7 шаг echo("\n7. Отсоеденится: "); echo (telegram.disconnect()); # конец echo("<hr><br>") # Quit app.quit()
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = Environment.GetEnvironmentVariable("RPABOT_HOST_URL"); InitXHE(); // начало echo("<hr><font color=blue>submitter.generate_random_city</font><hr>"); // получить можно тут : https://core.telegram.org/api var appID = "xxx"; var appHash = "xxx"; var myPhoneNumber="+7xxx"; var password="xxx"; // 1 шаг echo("1. Соединится с телеграм : "); echo(telegram.connect(appID, appHash)); // 2 шаг echo("\n2. Запросить авторизацию : "); var res = telegram.request_authorization(myPhoneNumber); echo(res); if (res!="connected") { // ввод кода верификации if (res=="verification_code") { var auth_code=app.get_dlg_input_string("dlg_1","Введите код авторизации из смс или чата:"); // 3 шаг echo("\n3. Авторизоваться : "); var res1 = telegram.authorization(myPhoneNumber,res,auth_code); echo(res1); } // ввод пароля if (res=="password") { var auth_code=app.get_dlg_input_string("dlg_1","Введите пароль:"); // 3 шаг echo("\n3. Авторизоваться : "); var res1 = telegram.authorization(myPhoneNumber,res,password); echo(res1); } if (res!="ok") { echo("\n4. Не удалось авторизоваться : "); app.quit(); } } // 5 шаг echo("\n5. Получить каналы : "); var chanels = telegram.get_chats("chanel"); echo(chanels.Count); // 6 шаг var from_index=13; var from_id =Convert.ToInt64(chanels[from_index]["id"]); var from_title=chanels[from_index]["title"]; var messages = telegram.get_chat_messages(from_id); var last_message_id = Convert.ToInt32(messages[messages.Count-1]["ID"]); var to_index=20; var to_id =Convert.ToInt64(chanels[to_index]["id"]); var to_title=chanels[to_index]["title"]; // 6 шаг echo("\n6. Репостнуть последнее сообщение из "+from_title+" в "+to_title+": "); echo(telegram.repost_message(from_id,last_message_id,to_id)); // 7 шаг echo("\n7. Отсоеденится: "); echo (telegram.disconnect()); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7040"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>seo.get_alexa_rank</font><hr>"); // получить можно тут : https://core.telegram.org/api appID = "xxx"; appHash = "xxx"; myPhoneNumber="xxx"; password="xxx" // 1 шаг echo("1. Соединится с телеграм : "); echo(telegram.connect(appID, appHash)); // 2 шаг echo("\n2. Запросить авторизацию : "); res = telegram.request_authorization(myPhoneNumber); echo(res); if (res!="connected") { // ввод кода верификации if (res=="verification_code") { auth_code=app.get_dlg_input_string("dlg_1","Введите код авторизации из смс или чата:"); // 3 шаг echo("\n3. Авторизоваться : "); res = telegram.authorization(myPhoneNumber,res,auth_code); echo(res); } // ввод пароля if (res=="password") { auth_code=app.get_dlg_input_string("dlg_1","Введите пароль:"); // 3 шаг echo("\n3. Авторизоваться : "); res = telegram.authorization(myPhoneNumber,res,password); echo(res); } if (res!="ok") { echo("\n4. Не удалось авторизоваться : "); app.quit(); } } // 5 шаг echo("\n5. Получить каналы : "); chanels = telegram.get_chats("chanel"); echo(chanels.length); // 6 шаг from_index=13; from_id =chanels[from_index].id; from_title=chanels[from_index].title; messages = telegram.get_chat_messages(from_id); last_message_id = messages[messages.length-1].ID; to_index=20; to_id =chanels[to_index].id; to_title=chanels[to_index].title; // 6 шаг echo("\n6. Репостнуть последнее сообщение из "+from_title+" в "+to_title+": "); echo(telegram.repost_message(from_id,last_message_id,to_id)); // 7 шаг echo("\n7. Отсоеденится: "); echo (telegram.disconnect()); // конец echo("\n"); // Quit app.quit();
=============================================
Telegram Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.