Exemplo n.º 1
0
        private async Task HandleMessagePush(BasicDeliverEventArgs ea)
        {
            var body = ea.Body;

            var message    = Encoding.UTF8.GetString(body);
            var messageObj = JsonConvert.DeserializeObject <MqMessage>(message);

            var tasks = new List <Task <Telegram.Bot.Types.Message> >();

            foreach (long receiverId in messageObj.Receivers)
            {
                tasks.Add(telegramContext.SendTextMessage(messageObj.Content, receiverId));
            }

            await Task.WhenAll(tasks.ToArray());

            if (!string.IsNullOrWhiteSpace(messageObj.Hook))
            {
                foreach (var task in tasks)
                {
                    var m = await task;
                    hookService.AddHook(m.MessageId, messageObj.Hook);
                }
            }
        }
Exemplo n.º 2
0
 public override Task SendResponse(TelegramContext telegramContext)
 {
     return(telegramContext.SendTextMessage(ResponseText, ChatId));
 }