public void Execute(Session session, CommandLine line)
 {
     if (session.IsAuthed())
     {
         var user = session.GetVariables().Inoreader.GetUserInfo();
         session.WriteLine(user.UserId);
     }
 }
 public void Execute(Session session, CommandLine line)
 {
     if (session.IsAuthed() && session.IsFeedsInitialized())
     {
         var inoreader = session.GetInoreader();
         var variables = session.GetVariables();
         inoreader.MarkAsRead(variables.FiltedItems.Select(z => z.Id).ToArray());
         variables.FiltedItems = null;
         session.WriteLine("done.");
     }
 }
        public void Execute(Session session, CommandLine line, int[] matchedGroupId)
        {
            var variables = session.GetVariables();

            Proxy inoreader = null;

            foreach (var id in matchedGroupId)
            {
                switch (id)
                {
                    case 0:
                        if (string.IsNullOrWhiteSpace(this.UserName))
                        {
                            session.WriteLine("username can not be white space.");
                            return;
                        }

                        if (string.IsNullOrWhiteSpace(this.Password))
                        {
                            session.WriteLine("password can not be white space.");
                            return;
                        }

                        inoreader = new Proxy("1000001033", "P2OzUTKYMooEz2aYTnB9qS98MIHWNj4B", this.UserName, this.Password);
                        inoreader.Authenticate();
                        break;

                    case 1:
                        if (string.IsNullOrWhiteSpace(this.Token))
                        {
                            session.WriteLine("token can not be white space.");
                            return;
                        }

                        inoreader = new Proxy("1000001033", "P2OzUTKYMooEz2aYTnB9qS98MIHWNj4B", this.Token);
                        break;
                }
            }

            Debug.Assert(inoreader != null);

            if (string.IsNullOrWhiteSpace(inoreader.Token))
            {
                session.WriteLine("get token failed.");
                return;
            }
            else
            {
                session.WriteLine($"got token: {inoreader.Token}");
                variables.Inoreader = inoreader;
            }
        }
 public void Subscriptions(Session session, CommandLine line)
 {
     if (session.IsAuthed())
     {
         var inoreader = session.GetInoreader();
         var subscriptions = inoreader.GetSubscriptions();
         session.GetVariables().Subscriptions = subscriptions;
         for (var i = 0; i < subscriptions.Count; i++)
         {
             var item = subscriptions[i];
             session.WriteLine($"[{i}] {item.Title}");
         }
     }
 }
        public void Feed(Session session, CommandLine line,
            [MethodParameter("id")][Alias("i")][Desciption("id of subscription")]
            int subscriptionId,
            [MethodParameter("count")][Alias("c")][Alias("n")][Desciption("count of feeds")]
            int? c = null,
            [MethodParameter("filter")][Alias("f")][Desciption("filter of feeds")]
            ItemsFilterEnum filter = ItemsFilterEnum.OnlyUnread)
        {
            if (session.IsAuthed())
            {
                var inoreader = session.GetInoreader();
                var variables = session.GetVariables();
                if (variables.Subscriptions == null)
                {
                    session.WriteLine("list sub before list feed.");
                    return;
                }
                if (subscriptionId < 0 || subscriptionId >= variables.Subscriptions.Count)
                {
                    session.WriteLine("invaild id.");
                    return;
                }
                var id = variables.Subscriptions[subscriptionId].Id;

                var count = c ?? 200;
                if (count < 1)
                {
                    session.WriteLine("count must > 0.");
                    return;
                }

                var items = inoreader.GetItems(id, filter: filter, count: count);
                variables.FiltedItems = items.Items;
                session.PrintItem();
            }
        }
 public void Execute(Session session, CommandLine line)
 {
     return;
 }