public async override Task Execute(Callback callback, IViberBotClient client) { TextMessage msg = SendShedule(callback); long result = await client.SendTextMessageAsync(msg); LeaguesCommand leaguesCommand = new LeaguesCommand(_leagueRepository, version); await leaguesCommand.Execute(callback, client); }
public async override Task Execute(Callback callback, IViberBotClient client) { PictureMessage msg = await GetImage(callback); long result = await client.SendPictureMessageAsync(msg); TeamsCommand teamsCommand = new TeamsCommand(_leagueRepository, version); await teamsCommand.Execute(callback, client); }
public void Init() { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); _authToken = config["authToken"]; _webhookUrl = config["webhookUrl"]; _adminId = config["adminId"]; _viberBotClient = new ViberBotClient(_authToken); }
public ViberBotService(IConfiguration configuration, IViberBotClient viberBotClient, IDataVersionRepository dataVersionRepository, IImageHelper imageHelper, IUserRepository userRepository, ILeagueRepository leagueRepository, IScheduleRepository scheduleRepository, IMapper mapper) { _mapper = mapper; _viberBotClient = viberBotClient; _userRepository = userRepository; _leagueRepository = leagueRepository; _scheduleRepository = scheduleRepository; _dataVersionRepository = dataVersionRepository; _imageHelper = imageHelper; _webHook = configuration["WebHook"]; _viberUrl = "/api/viber/update"; }
public async override Task Execute(Callback callback, IViberBotClient client) { KeyboardMessage msg = await GetTeams(callback); long result = await client.SendKeyboardMessageAsync(msg); }
// ### Methods --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- #region Methods // *** Service *** *** *** *** *** *** *** *** *** *** *** *** *** *** #region Service /// <summary> /// Установить. Настройки /// </summary> public void SetSetting() { _authToken = "ХХХХХХХ"; _viberBotClient = new ViberBotClient(_authToken); }
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; } } }
public abstract Task Execute(Callback callback, IViberBotClient client);
public ViberMessageSender(IViberBotClient viber) { _viber = viber; }
public SendMessageService(IBotFactory <IViberBotClient> viberBotFactory) { var botId = 1; this.viberBotClient = viberBotFactory.GetClient(botId); }