private static async Task UserOder(long TlgUserID, string PublicToken, int intBetType, int intAmount) { ReturnOrderModel ObjO = await IbrokersProcess.BetProcessAsync(PublicToken, intBetType, intAmount); if (ObjO.errorCode == 0) //Order thành công. { string strMsg = intBetType == 0 ? "Sell: " : "Buy: "; strMsg = strMsg + intAmount.ToString(); await botClient.SendTextMessageAsync(TlgUserID, strMsg); //send cho user biêt. } else { await botClient.SendTextMessageAsync(TlgUserID, ObjO.errorMessage); } //string SendMSG = await strMsg; //intBetType ==0? "Sell: ":"Buy: " + intAmount.ToString() }
static string PublicToken = string.Empty; //token de lay thong tin tu server. static async Task Main() { //khoi tao thong tin bot telegram ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; botClient = new TelegramBotClient("1206806449:AAHb5mWsgev-vl0R0qmN6PWzQQO_k75QiLM"); //lay bot telegram. botClient.OnMessage += BotClient_OnMessage; //dang ky su kien nhan tin tu user vào bot botClient.StartReceiving(); // //lay token public de truy van tin hieu Task <string> strToken = IbrokersProcess.GetToken("D116771", "123456789"); PublicToken = await strToken; //lay và gởi tin hieu cho user. string strPayout = string.Empty; List <PriceModel> ListPayout = null; while (true) { ListPayout = await IbrokersProcess.GetPriceCandlesticks(PublicToken); strPayout = string.Empty; //char.ConvertFromUtf32(0x1F534) + char.ConvertFromUtf32(0x1F7E2) + char.ConvertFromUtf32(0x1F534); foreach (PriceModel item in ListPayout) { if (item.close > item.open) //Buy { strPayout = char.ConvertFromUtf32(0x1F7E2) + strPayout; } else //sell { strPayout = char.ConvertFromUtf32(0x1F534) + strPayout; } } if (ListUserSign.Count > 0) { foreach (long UserChatID in ListUserSign) { SendPayout(UserChatID, strPayout); } DateTime CurenTime = DateTime.Now; await Task.Delay((61 - CurenTime.Second) * 1000); } } //Thread.Sleep(int.MaxValue); //Console.WriteLine(strABC); //Console.ReadLine(); //ServicePointManager.Expect100Continue = true; //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //botClient = new TelegramBotClient("1206806449:AAHb5mWsgev-vl0R0qmN6PWzQQO_k75QiLM"); //var me = botClient.GetMeAsync().Result; //Console.WriteLine( // $"Hello, World! I am user {me.Id} and my name is {me.FirstName}." //); ////Console.ReadLine(); //while (true) //{ //} //Thread.Sleep(int.MaxValue); }