Exemple #1
0
        public void Execute()
        {
            Response <IList <RssEntity> > rssRemove = _queryRssService.GetList(_callbackQueryEventArgs.CallbackQuery.From.Id);

            InlineKeyboardButton[][] keyboardButtonsListrssRemove = new InlineKeyboardButton[rssRemove.ResponseData.Count + 1][];
            keyboardButtonsListrssRemove = new InlineKeyboardButton[rssRemove.ResponseData.Count + 1][];

            for (int i = 0; i < rssRemove.ResponseData.Count; i++)
            {
                int count = _queryRssChatRelationService.GetList(_callbackQueryEventArgs.CallbackQuery.From.Id, rssRemove.ResponseData[i].AliasName, CDO.Enums.Chat.ListChatRelation.ByAliasName).ResponseData.Count;
                if (count.Equals(0))
                {
                    keyboardButtonsListrssRemove[i] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData(rssRemove.ResponseData[i].AliasName, string.Concat("RemoveRss_", rssRemove.ResponseData[i].Id)) }
                }
                ;
            }

            keyboardButtonsListrssRemove[rssRemove.ResponseData.Count] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Back to Home") };

            _telegramBotClient.EditMessageTextAsync(
                _callbackQueryEventArgs.CallbackQuery.From.Id,
                _callbackQueryEventArgs.CallbackQuery.Message.MessageId,
                "you can only remove rss that is not attached to any group or channel. listed below that is not attached to any group or channel.",
                replyMarkup: new InlineKeyboardMarkup(keyboardButtonsListrssRemove.Where(x => x != null).ToArray())).GetAwaiter();
        }
    }
        public void Execute()
        {
            Response <IList <ChannelEntity> > channelsRemove = _queryChannelService.GetList(_callbackQueryEventArgs.CallbackQuery.From.Id, CDO.Enums.Chat.ChatType.Group);

            InlineKeyboardButton[][] keyboardButtonsListChannelsRemove = new InlineKeyboardButton[channelsRemove.ResponseData.Count + 1][];
            keyboardButtonsListChannelsRemove = new InlineKeyboardButton[channelsRemove.ResponseData.Count + 1][];

            for (int i = 0; i < channelsRemove.ResponseData.Count; i++)
            {
                int count = _queryRssChatRelationService.GetList(_callbackQueryEventArgs.CallbackQuery.From.Id, channelsRemove.ResponseData[i].Name, CDO.Enums.Chat.ListChatRelation.ByChatName).ResponseData.Count;
                if (count.Equals(0))
                {
                    keyboardButtonsListChannelsRemove[i] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData(channelsRemove.ResponseData[i].Name, string.Concat("RemoveGroup_", channelsRemove.ResponseData[i].Name)) }
                }
                ;
            }

            keyboardButtonsListChannelsRemove[channelsRemove.ResponseData.Count] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Back to Home") };

            _telegramBotClient.EditMessageTextAsync(
                _callbackQueryEventArgs.CallbackQuery.From.Id,
                _callbackQueryEventArgs.CallbackQuery.Message.MessageId,
                "to remove channel, choose one.",
                replyMarkup: new InlineKeyboardMarkup(keyboardButtonsListChannelsRemove.Where(x => x != null).ToArray())).GetAwaiter();
        }
    }
        public BotKickedException(Exception exception, MessagingPlatform messagingPlatform)
        {
            if (exception.Message.Equals(BOT_KICKED))
            {
                IQueryRssChatRelationService   queryRssChatRelationService   = messagingPlatform.Resolve <IQueryRssChatRelationService>();
                ICommandRssChatRelationService commandRssChatRelationService = messagingPlatform.Resolve <ICommandRssChatRelationService>();

                Response <IList <RssChatRelationEntity> > response = queryRssChatRelationService.GetList(LifeTimeCycle.LifeTimeCycle.ExceptionChat);
                foreach (var item in response.ResponseData)
                {
                    commandRssChatRelationService.Remove(item);
                }

                return;
            }
            //new Exception(exception);
        }
        public static void SyncList(ReaderPlatform readerPlatform)
        {
            _queryRssChat = readerPlatform.Resolve <IQueryRssChatRelationService>();
            var datas = _queryRssChat.GetList().ResponseData;

            RssList = RssList.Where(x => datas.Select(y => y.Id).Contains(x.Key.Id)).ToDictionary(x => x.Key, y => y.Value);

            foreach (var item in datas)
            {
                if (RssList.Select(x => x.Key.Id).Contains(item.Id))
                {
                    continue;
                }
                else
                {
                    RssList.Add(item, DateTimeOffset.Now);
                }
            }
        }
        public void Execute()
        {
            Response <IList <ChannelEntity> > channels = _queryChannelService.GetList(_callbackQueryEventArgs.CallbackQuery.From.Id, CDO.Enums.Chat.ChatType.Group);

            InlineKeyboardButton[][] keyboardButtonsListChannels = new InlineKeyboardButton[channels.ResponseData.Count + 1][];
            keyboardButtonsListChannels = new InlineKeyboardButton[channels.ResponseData.Count + 1][];

            for (int i = 0; i < channels.ResponseData.Count; i++)
            {
                int count = _queryRssChatRelationService.GetList(_callbackQueryEventArgs.CallbackQuery.From.Id, channels.ResponseData[i].Name, CDO.Enums.Chat.ListChatRelation.ByChatName).ResponseData.Count;
                keyboardButtonsListChannels[i] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData(string.Concat(channels.ResponseData[i].Name, " (", count, ")"), string.Concat("Group_", channels.ResponseData[i].Id)) };
            }

            keyboardButtonsListChannels[channels.ResponseData.Count] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Back to Home") };

            _telegramBotClient.EditMessageTextAsync(
                _callbackQueryEventArgs.CallbackQuery.From.Id,
                _callbackQueryEventArgs.CallbackQuery.Message.MessageId,
                "you can attach rss to selected group from rss list.",
                replyMarkup: new InlineKeyboardMarkup(keyboardButtonsListChannels)).GetAwaiter();
        }
Exemple #6
0
        public void Execute()
        {
            Response <IList <RssEntity> > rss = _queryRssService.GetList(_callbackQueryEventArgs.CallbackQuery.From.Id);

            if (!rss.ResponseData.Count.Equals(0))
            {
                InlineKeyboardButton[][] keyboardButtonsListrss = new InlineKeyboardButton[rss.ResponseData.Count + 1][];
                keyboardButtonsListrss = new InlineKeyboardButton[rss.ResponseData.Count + 1][];

                for (int i = 0; i < rss.ResponseData.Count; i++)
                {
                    int count = _queryRssChatRelationService.GetList(rss.ResponseData[i].AliasName).ResponseData.Count;
                    keyboardButtonsListrss[i] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData(string.Concat(rss.ResponseData[i].AliasName, " (", count, ")"), string.Concat("Rss_", rss.ResponseData[i].AliasName)) };
                }

                keyboardButtonsListrss[rss.ResponseData.Count] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Back to Home") };

                _telegramBotClient.EditMessageTextAsync(
                    _callbackQueryEventArgs.CallbackQuery.From.Id,
                    _callbackQueryEventArgs.CallbackQuery.Message.MessageId,
                    "in order to list atached groups and channels, choose one.",
                    replyMarkup: new InlineKeyboardMarkup(keyboardButtonsListrss)).GetAwaiter();
            }
            else
            {
                InlineKeyboardButton[][] keyboardButtonsListrss = new InlineKeyboardButton[2][];
                keyboardButtonsListrss = new InlineKeyboardButton[2][];

                keyboardButtonsListrss[0] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Add Rss") };
                keyboardButtonsListrss[1] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Back to Home") };

                _telegramBotClient.EditMessageTextAsync(
                    _callbackQueryEventArgs.CallbackQuery.From.Id,
                    _callbackQueryEventArgs.CallbackQuery.Message.MessageId,
                    "you don't have any rss link.",
                    replyMarkup: new InlineKeyboardMarkup(keyboardButtonsListrss)).GetAwaiter();
            }
        }
        public void Execute()
        {
            Response <IList <RssChatRelationEntity> > rss = _queryRssChatService.GetList(_callbackQueryEventArgs.CallbackQuery.From.Id, _callbackQueryEventArgs.CallbackQuery.Data.Substring(4, _callbackQueryEventArgs.CallbackQuery.Data.Length - 4), CDO.Enums.Chat.ListChatRelation.ByAliasName);

            InlineKeyboardButton[][] keyboardButtonsListrss = new InlineKeyboardButton[rss.ResponseData.Count + 1][];
            keyboardButtonsListrss = new InlineKeyboardButton[rss.ResponseData.Count + 1][];

            for (int i = 0; i < rss.ResponseData.Count; i++)
            {
                keyboardButtonsListrss[i] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData(rss.ResponseData[i].Name, string.Concat("Remove_Rss_", rss.ResponseData[i].Id)) }
            }
            ;

            keyboardButtonsListrss[rss.ResponseData.Count] = new InlineKeyboardButton[] { InlineKeyboardButton.WithCallbackData("Back to Home") };

            _telegramBotClient.EditMessageTextAsync(
                _callbackQueryEventArgs.CallbackQuery.From.Id,
                _callbackQueryEventArgs.CallbackQuery.Message.MessageId,
                "in order to remove rss from channel or group, choose one.",
                replyMarkup: new InlineKeyboardMarkup(keyboardButtonsListrss)).GetAwaiter();

            SessionHelper.GetSession(_callbackQueryEventArgs.CallbackQuery.From.Id).InstructionId = CDO.Enums.TLBot.NextInstruction.RemoveChannelGroupFromRss;
        }
    }
 public static void Load(ReaderPlatform readerPlatform)
 {
     _queryRssChat = readerPlatform.Resolve <IQueryRssChatRelationService>();
     RssList       = _queryRssChat.GetList().ResponseData.ToDictionary(x => x, x => DateTimeOffset.Now);
 }