internal static Task Send(SocketMessage message) { if (!message.Author.IsBot) { if (message.Content.Contains(Program.commandChar)) { if (!UserTools.UserExists(message.Author.Id)) { Program.userList.Add(new User(message.Author.Id)); FileManipulation.LoadFile(message.Author.Id.ToString()); } try { string command = message.Content.Split(Program.commandChar)[0]; string rest = message.Content.Remove(0, command.Length + 1).Trim('|'); string[] content = rest.Split(Program.splitChar); CommandHandler.Send(message.Author.Id, command, content); } catch { message.Author.SendMessageAsync("Command is not correctly formatted, please try again or contact an administrator."); } } } return(Task.CompletedTask); }
internal static void Add(string[] content) { Group group = GetGroup(content[0]); content = UserTools.RemoveFirst(content); group.Info.Add(new Information(content)); }
internal static void CreateGroup(ulong id, string[] content) { User[] usersToAdd = new User[content.Length + 1]; for (int i = 0; i < usersToAdd.Length; i++) { if (i == 0) { usersToAdd[0] = UserTools.GetUser(id); } else { usersToAdd[i] = UserTools.GetUser(Convert.ToUInt64(content[i - 1])); } } Program.groupList.Add(new Group(usersToAdd)); }
internal static void LoadFile(string id) { string input = File.ReadAllText(id); string[] sqbr = input.Split('['); sqbr = UserTools.RemoveFirst(sqbr); string[] crbr = sqbr[0].Split('{'); crbr = UserTools.RemoveFirst(crbr); foreach (var text in crbr) { string[] words = text.Split('|'); try { Group group = GroupTools.GetGroup(id); group.Info.Add(new Information(words)); } catch { } } }
internal static void Send(ulong id, string command, string[] content) { /*commands to copypaste * § = command character * | = break character * * + = add entry to personal list * ++ add to the end of an existing entry * ? search for keyword * ?? display all of your information * * &+ create a group * * G+ add entry to group list * G? search for entry in group list * * examples: * +§shopping list|5 apples|6 lentils|bucket of milk|metric ton of meat * * ?§shopping list * ?§shopping * * G+§235921495236940355|daniel|charmeleon * G+§235921495236940355|marius|blastoise * * G?§235921495236940355|caterpie */ User user = UserTools.GetUser(id); switch (command) { case "queue": QueueTools.TryCreate(id, Convert.ToUInt64(content[0]), content[1]); break; case "remind": ReminderTools.TryCreate(id, content[0], content[1]); break; case "+": UserTools.Add(id, content); UserTools.SaveAll(); break; case "++": UserTools.ConcatContent(id, content); UserTools.SaveAll(); break; case "?": Program._client.GetUser(id).SendMessageAsync(UserTools.GetAllContent(id, content[0])); break; case "??": Program._client.GetUser(id).SendMessageAsync(UserTools.GetAllContent(id)); break; case "&+": GroupTools.CreateGroup(id, content); break; case "G+": GroupTools.Add(content); GroupTools.SaveAll(); break; case "G?": Program._client.GetUser(id).SendMessageAsync(GroupTools.GetAllContent(content)); break; default: break; } return; }