public async Task SendBroadcastMessage() { IEnumerable <User> users = await _userRepository.GetAll(); IEnumerable <string> viberUserIds = users.Where(w => w.IsViber).Select(x => x.ClientId).ToList(); int lastVersion = await _dataVersionRepository.GetLastVersion(); BroadcastMessage broadcastMessage = new BroadcastMessage("oFKwijuinRXIqIUwBvbpEw=="); broadcastMessage.Sender = new UserBase { Name = MessageConstant.BOT_NAME, Avatar = MessageConstant.BOT_AVATAR }; broadcastMessage.BroadcastList = viberUserIds; broadcastMessage.MinApiVersion = 2; broadcastMessage.Text = MessageConstant.UPDATE; await _viberBotClient.SendBroadcastMessageAsync(broadcastMessage); LeaguesCommand leaguesCommand = new LeaguesCommand(_leagueRepository, lastVersion); foreach (var id in viberUserIds) { var callback = new Callback(); callback.Sender = new UserModel(); callback.Sender.Id = id; await leaguesCommand.Execute(callback, _viberBotClient); } }
public async Task SendBroadcastMessageAsyncTest() { var result = await _viberBotClient.SendBroadcastMessageAsync(new BroadcastMessage { Sender = new UserBase { Name = "Smbdy" }, Text = "Broadcast message!:)", BroadcastList = new [] { _adminId } }); return; }