public static void FillWithDefaultData(string name) { var client = ViberBotClient.GetInstance(); var googleSheetsClient = GoogleSheetsClient.GetInstanse(); if (!googleSheetsClient.IsSheetExist(name)) { return; } var firstRow = new List <object>(); firstRow.Add(flatColName); firstRow.AddRange(GetMonthNames()); firstRow.Add(dateColName); firstRow.Add(idColName); firstRow.Add(whoColName); googleSheetsClient.UpdateData(1, 1, firstRow, name); var flatNumbersColumn = new List <object>(); flatNumbersColumn.AddRange(Enumerable.Range(1, client.Settings.FlatsNumber).Select(x => x.ToString())); googleSheetsClient.UpdateColData(2, 1, flatNumbersColumn, name); }
public static async Task Execute(CallbackData data) { var receiver = data.Sender.Id; if (int.TryParse(((TextMessage)data.Message).Text, out int userValue)) { //учесть данные в поле трекинга var flats = Handlers.GoogleSheetsHandler.CheckFlatData(data.Sender.Id); if (flats.Any(f => f.ToString() == userValue.ToString())) { await client.SendTextMessage(receiver, $"Вы указали - {userValue}. Уже в списке."); } else if (userValue <= 0 || userValue > ViberBotClient.GetInstance().Settings.FlatsNumber) { await client.SendTextMessage(receiver, $"Вы указали - {userValue}. Номер квартиры должен быть от 1 до {ViberBotClient.GetInstance().Settings.FlatsNumber}."); } else { var trackingData = ViberBotTrackingData.Get(data.Message.TrackingData); trackingData.Add(DataField.FlatNumber.ToString(), userValue.ToString()); //запросить подтверждение var message = new KeyboardMessage { Receiver = receiver, Sender = client.BotUserData, Text = $"Вы указали - {userValue}. Данные верны?", TrackingData = ViberBotTrackingData.Build("СonfirmSetFlatNumberAction", "SetFlatNumberAction", trackingData.Data), Keyboard = KeyboardHandler.YesNoCancel() }; await client.SendMessage(receiver, message); } } else { //неверное значение await client.SendTextMessage(receiver, BotError.BadValue); } }
public async Task <ICollection <EventType> > SetWebhookAsync(string url) { return(await ViberBotClient.GetInstance().SetWebhookAsync($"{url}/api/Webhook")); }