public static void Important(string[] args, AppData appData) { uint n = 0; new OptionSet() { { "n=", _ => n = Convert.ToUInt32(_) } }.Parse(args); CliUtils.Validate(n > 0, AppError.ErrorCode.ArgumentParseError, $"should pass the number of messages to retrieve (-n=..)"); var vk = new VkApi(); vk.Authorize(appData.AccessToken); var messages = vk.Messages.Get(new MessagesGetParams() { Count = n, Filters = MessagesFilter.Important, }).Messages; CliUtils.PresentField("Messages", messages.Count); foreach (var m in messages) { Console.WriteLine(); CliUtils.PresentMessage(m, appData); } }
public static void Chat(string[] args, AppData appData) { int p = -1; bool room = false; string[] opts = new OptionSet() { { "p=|prev=", _ => p = Convert.ToInt32(_) }, { "R|room", _ => room = true }, }.Parse(args).ToArray(); long id = appData.GetId(opts.GetArg(1)); bool?roomAbbr = appData.IsRoom(opts.GetArg(1)); if (roomAbbr.HasValue && roomAbbr.Value != room) { Console.WriteLine($"Warning: setting -R|--room flag to {roomAbbr.Value} according to abbreviations data."); room = roomAbbr.Value; } var vk = new VkApi(); vk.Authorize(appData.AccessToken); var msgs = MiscUtils.RecvMessages(vk, id, p >= 0 ? (int?)p : null, false, false); Console.WriteLine("Entering chat mode. Press enter at any time to begin typing."); if (!room) { CliUtils.PresentField("Buddy", appData.GetAbbr(id)); } else { CliUtils.PresentField("Room", appData.GetAbbr(id)); } if (p != 0) { foreach (var m in msgs) { Console.WriteLine(); CliUtils.PresentMessage(m, appData); } } CliUtils.LaunchChatMode(vk, appData, id, room); }
public void Display() { if (Incoming_.Count == 0) { return; } foreach (var msg in Incoming_) { Console.WriteLine(); CliUtils.PresentMessage(msg, AppData); } Incoming_.Clear(); HorizontalLine(); }
public static void Recv(string[] args, AppData appData) { bool quiet = false; bool all = false; uint n = 200; bool reverse = false; bool room = false; string[] opts = new OptionSet() { { "q|quiet", _ => quiet = true }, { "a=|all=", _ => { all = true; n = Convert.ToUInt32(_); } }, { "r|reverse", _ => reverse = true }, { "R|room", _ => room = true }, }.Parse(args).ToArray(); long id = appData.GetId(opts.GetArg(1)); bool?roomAbbr = appData.IsRoom(opts.GetArg(1)); if (roomAbbr.HasValue && roomAbbr.Value != room) { Console.WriteLine($"Warning: setting -R|--room flag to {roomAbbr.Value} according to abbreviations data."); room = roomAbbr.Value; } var vk = new VkApi(); vk.Authorize(appData.AccessToken); var msgs = MiscUtils.RecvMessages(vk, id, all ? (int?)n : null, reverse, quiet); if (msgs.Count > 0) { CliUtils.PresentField("Messages", msgs.Count, ConsoleColor.Magenta); CliUtils.PresentField("Quiet", quiet); foreach (var m in msgs) { Console.WriteLine(); CliUtils.PresentMessage(m, appData); } } }