public async Task SendKeyboardMessageAsyncTest() { var result = await _viberBotClient.SendKeyboardMessageAsync(new KeyboardMessage { Receiver = _adminId, Sender = new UserBase { Name = "Smbdy" }, Text = "Test keyboard", Keyboard = new Keyboard { Buttons = new[] { new KeyboardButton { Text = "Button 1", ActionBody = "AB1" } } }, TrackingData = "td" }); return; }
public async Task <OperationResult> SendTextAsync(ViberMessage message) { if (message == null) { throw new ArgumentNullException(nameof(ViberMessage)); } var result = await _viber.SendKeyboardMessageAsync(new KeyboardMessage { Receiver = message.Receiver, Text = message.Text, Sender = new UserBase { Name = message.SenderDisplayName }, Keyboard = message.Keyboard }); return(result == 0 ? new OperationResult(Constants.Error) : new OperationResult()); }
public async Task SendKeyboardMessageAsync(int botId, string receiverId, OutMessage message) { // var buttons = message.Buttons.Select(button => { var keyboardButton = new KeyboardButton { Text = button.Title, // ActionBody = "Helllo", ActionType = KeyboardActionType.LocationPicker, Columns = button.Columns, Rows = button.Rows }; if (button.Style != null) { keyboardButton.BackgroundColor = button.Style.BackgroundColor; keyboardButton.TextHorizontalAlign = button.Style.TextHorizontalAlign.ToTextHorizontalAlign(); keyboardButton.TextVerticalAlign = button.Style.TextVerticalAlign.ToTextVerticalAlign(); keyboardButton.TextSize = button.Style.TextSize.ToTextSize(); } return(keyboardButton); }); // var keyboardMessage = new KeyboardMessage { Receiver = receiverId, MinApiVersion = 4, Text = message.Text, Keyboard = new Keyboard { Buttons = buttons.ToList() } }; await viberBotClient.SendKeyboardMessageAsync(keyboardMessage); }
public async override Task Execute(Callback callback, IViberBotClient client) { KeyboardMessage msg = await GetTeams(callback); long result = await client.SendKeyboardMessageAsync(msg); }
public static async void SendNextMessage(DialogueFrame df, HealthBotContext ctx, users dbUser, CallbackData callbackData, IViberBotClient client) { string message = ""; Keyboard keyboard; string[] buttons = null; if (df.Activity == EnumActivity.Unknown) { if (df.Entity != "") { message = df.Entity; } else { return; } } else { message = await GetNextMessage(df, dbUser, ctx, buttons); if (df.Activity == EnumActivity.CallHuman) { dbUser.id_last_question = null; dbUser.is_last_question_system = null; dbUser.chatting = "viber"; } if (dbUser.is_last_question_system.HasValue) { //если нужно прислать картинку if (dbUser.is_last_question_system.Value == true && dbUser.id_last_question == (int)SystemMessages.SendBiomark_plot) { using (Stream stream = System.IO.File.OpenRead(dbUser.token + ".png")) { await client.SendPictureMessageAsync( new PictureMessage() { Text = "Ваш график", Receiver = callbackData.Sender.Id, MinApiVersion = callbackData.Message.MinApiVersion, TrackingData = callbackData.Message.TrackingData, Media = "https://upload.wikimedia.org/wikipedia/commons/5/57/Viber-logo.png" //viber is lame } ); } dbUser.id_last_question = null; dbUser.is_last_question_system = null; } } if (message != "") { dbUser.id_last_question = (int?)df.Tag; if (buttons != null) { keyboard = new Keyboard() { BackgroundColor = "#32C832", Buttons = buttons.Select(t => new Viber.Bot.KeyboardButton() { Text = t }).ToList() }; await client.SendKeyboardMessageAsync(new KeyboardMessage { Text = message, Keyboard = keyboard, Receiver = callbackData.Sender.Id, MinApiVersion = callbackData.Message.MinApiVersion, TrackingData = callbackData.Message.TrackingData }); } else { await client.SendTextMessageAsync(new TextMessage() { Text = message, Receiver = callbackData.Sender.Id, MinApiVersion = callbackData.Message.MinApiVersion, TrackingData = callbackData.Message.TrackingData }); } } else { dbUser.id_last_question = null; } } }