public override string GetResponse(string c, Summoner s) { var parts = c.Split(); if (!Commands.ContainsKey(parts[0])) { return(""); } if (!HasRights(Commands[parts[0]].AuthRank, s)) { return(""); } var args = string.Empty; for (var i = 1; i < parts.Length; i++) { args += string.Format("{0} ", parts[i]); } args = args.Trim(); switch (parts[0]) { case "!ban": return(Ban(args)); case "!unban": return(UnBan(args)); case "!register": return(Register(s.Name)); case "!sukkel": return(string.Format("{0} is een sukkel", RandomFromRoom())); case "!setrank": return(SetRank(args)); case "!beasts3sukkelsoftheday": return(ThreeSukkels()); default: return(""); } }
public virtual string GetResponse(string c, Summoner s) { var parts = c.Split(); if (!Commands.ContainsKey(parts[0])) { return(""); } var args = string.Empty; for (var i = 1; i < parts.Length; i++) { args += string.Format("{0} ", parts[i]); } var com = Commands[parts[0]]; return(HasRights(com.AuthRank, s) ? com.GetResponse(args.TrimEnd()) : ""); }
public bool HasRights(string required, Summoner has) { if (required.Equals(has.Rank) || required.Equals(has.Name)) { return(true); } var authlevels = new List <string> { "admin", "mod", "normal" }; if (authlevels.Contains(required) && required.Equals(has.Rank)) { return(true); } if (required.Equals("mod") && has.Rank.Equals("admin")) { return(true); } return(required.Equals("normal") && has.Rank.Equals("admin") || has.Rank.Equals("mod")); }
public string Register(string name) { if (_registeredUsers.ContainsKey(name)) { return(string.Format("{0} is already a registered user!", name)); } var summoner = _api.SummonerIdByName(name); var id = summoner.id; var oldName = NameFromId(id); if (!oldName.Equals(string.Empty)) { return(Update(oldName, id, name)); } var newUser = new Summoner(id.ToString(), summoner.name, "normal"); _registeredUsers.Add(newUser.Name, newUser); FlushUsers(); return(string.Format("{0} registered!", newUser.Name)); }
public static String UserToString(Summoner b) { return(string.Format("{0}~{1}~{2}", b.Summonerid, b.Name, b.Rank)); }
private void FlushUsers() { var s = _registeredUsers.Aggregate(string.Empty, (current, registeredUser) => current + (Summoner.UserToString(registeredUser.Value) + Environment.NewLine)); File.WriteAllText(Settings.Default.Users, s); Console.WriteLine("Registered users flushed to disk."); }