public static bool SetCfgValue(IConfiguration cfg, ITriggerer trigger) { if (trigger.Text.HasNext) { string name = trigger.Text.NextWord(); string remainder = trigger.Text.Remainder; if (remainder.Length == 0) { trigger.Reply("No arguments given."); return(false); } if (cfg.Contains(name)) { if (cfg.Set(name, remainder)) { trigger.Reply("Variable \"{0}\" is now set to: " + remainder, (object)name); return(true); } trigger.Reply("Unable to set Variable \"{0}\" to value: {1}.", (object)name, (object)remainder); } else { trigger.Reply("Variable \"{0}\" does not exist.", (object)name); } } return(false); }
public static bool GetCfgValue(IConfiguration cfg, ITriggerer trigger) { if (trigger.Text.HasNext) { string name = trigger.Text.NextWord(); object val = cfg.Get(name); if (val != null) { if (cfg is VariableConfiguration <WCellVariableDefinition> && ((VariableConfiguration <WCellVariableDefinition>)cfg).GetDefinition(name).IsFileOnly) { trigger.Reply("Cannot display variable: \"{0}\"", (object)name); return(false); } trigger.Reply("Variable {0} = {1}", (object)name, (object)Utility.GetStringRepresentation(val)); return(true); } trigger.Reply("Variable \"{0}\" does not exist.", (object)name); return(true); } trigger.Reply("No arguments given."); return(false); }
public static bool GetCfgValue(IConfiguration cfg, ITriggerer trigger) { if (trigger.Text.HasNext) { var name = trigger.Text.NextWord(); //if (def.MaySet(trigger.Args.Role)) var val = cfg.Get(name); if (val != null) { if (cfg is VariableConfiguration <WCellVariableDefinition> ) { var vcfg = (VariableConfiguration <WCellVariableDefinition>)cfg; var def = vcfg.GetDefinition(name); if (def.IsFileOnly) { trigger.Reply("Cannot display variable: \"{0}\"", name); return(false); } } trigger.Reply("Variable {0} = {1}", name, Utility.GetStringRepresentation(val)); return(true); } trigger.Reply("Variable \"{0}\" does not exist.", name); //else //{ // trigger.Reply("You do not have enough privileges to set Variable \"{0}\".", def.Name); //} return(true); } trigger.Reply("No arguments given."); return(false); }
public static IConfiguration GetConfig(IConfiguration deflt, ITriggerer trigger) { IConfiguration configuration; if (trigger.Text.NextModifiers() == "a") { string shortName = trigger.Text.NextWord(); IWCellAddon addon = WCellAddonMgr.GetAddon(shortName); if (addon == null) { trigger.Reply("Did not find any Addon matching: " + shortName); return((IConfiguration)null); } configuration = addon.Config; if (configuration == null) { trigger.Reply("Addon does not have a Configuration: " + (object)addon); return((IConfiguration)null); } } else { configuration = deflt; } return(configuration); }
public static IConfiguration GetConfig(IConfiguration deflt, ITriggerer trigger) { IConfiguration cfg; if (trigger.Text.NextModifiers() == "a") { var shortName = trigger.Text.NextWord(); var addon = WCellAddonMgr.GetAddon(shortName); if (addon == null) { trigger.Reply("Did not find any Addon matching: " + shortName); return null; } cfg = addon.Config; if (cfg == null) { trigger.Reply("Addon does not have a Configuration: " + addon); return null; } } else { cfg = deflt; } return cfg; }
public static IConfiguration GetConfig(IConfiguration deflt, ITriggerer trigger) { IConfiguration cfg; if (trigger.Text.NextModifiers() == "a") { var shortName = trigger.Text.NextWord(); var addon = WCellAddonMgr.GetAddon(shortName); if (addon == null) { trigger.Reply("Did not find any Addon matching: " + shortName); return(null); } cfg = addon.Config; if (cfg == null) { trigger.Reply("Addon does not have a Configuration: " + addon); return(null); } } else { cfg = deflt; } return(cfg); }
public static void ListCfgValues(IConfiguration cfg, ITriggerer trigger) { var vars = new List <IVariableDefinition>(50); var filter = trigger.Text.Remainder; if (filter.Length > 0) { cfg.Foreach((def) => { if (!def.IsFileOnly && def.Name.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) >= 0) { vars.Add(def); } }); if (vars.Count == 0) { trigger.Reply("Could not find any readable globals that contain \"{0}\".", filter); } } else { cfg.Foreach(def => { if (!def.IsFileOnly) { vars.Add(def); } }); if (vars.Count == 0) { trigger.Reply("No readable variables found."); } } if (vars.Count > 0) { vars.Sort(); trigger.Reply("Found {0} globals:", vars.Count); foreach (var var in vars) { trigger.Reply(var.Name + " = " + var.GetFormattedValue()); } } }
public static void ListCfgValues(IConfiguration cfg, ITriggerer trigger) { List <IVariableDefinition> vars = new List <IVariableDefinition>(50); string filter = trigger.Text.Remainder; if (filter.Length > 0) { cfg.Foreach((Action <IVariableDefinition>)(def => { if (def.IsFileOnly || def.Name.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) < 0) { return; } vars.Add(def); })); if (vars.Count == 0) { trigger.Reply("Could not find any readable globals that contain \"{0}\".", (object)filter); } } else { cfg.Foreach((Action <IVariableDefinition>)(def => { if (def.IsFileOnly) { return; } vars.Add(def); })); if (vars.Count == 0) { trigger.Reply("No readable variables found."); } } if (vars.Count <= 0) { return; } vars.Sort(); trigger.Reply("Found {0} globals:", (object)vars.Count); foreach (IVariableDefinition def in vars) { trigger.Reply(def.Name + " = " + def.GetFormattedValue()); } }
public void Display(ITriggerer triggerer, string info) { triggerer.Reply("-------------"); triggerer.Reply("| " + info + Type + " in " + m_Map.Name + " |"); triggerer.Reply("-------------------------------------------------------------------"); triggerer.Reply("| by " + m_ownerName + (m_owner == null ? " (Offline)" : "") + ", " + Age + " ago."); triggerer.Reply("-------------------------------------------------------------------"); triggerer.Reply(Message); triggerer.Reply("-------------------------------------------------------------------"); }
public void Display(ITriggerer triggerer, string info) { triggerer.Reply("-------------"); triggerer.Reply("| " + info + (object)this.Type + " in " + this.m_Map.Name + " |"); triggerer.Reply("-------------------------------------------------------------------"); triggerer.Reply("| by " + this.m_ownerName + (this.m_owner == null ? (object)" (Offline)" : (object)"") + ", " + (object)this.Age + " ago."); triggerer.Reply("-------------------------------------------------------------------"); triggerer.Reply(this.Message); triggerer.Reply("-------------------------------------------------------------------"); }
public static bool SetCfgValue(IConfiguration cfg, ITriggerer trigger) { if (trigger.Text.HasNext) { var name = trigger.Text.NextWord(); var value = trigger.Text.Remainder; if (value.Length == 0) { trigger.Reply("No arguments given."); return false; } if (cfg.Contains(name)) { //if (def.MaySet(trigger.Args.Role)) if (cfg.Set(name, value)) { trigger.Reply("Variable \"{0}\" is now set to: " + value, name); return true; } else { trigger.Reply("Unable to set Variable \"{0}\" to value: {1}.", name, value); } //else //{ // trigger.Reply("You do not have enough privileges to set Variable \"{0}\".", def.Name); //} } else { trigger.Reply("Variable \"{0}\" does not exist.", name); } } return false; }
public static bool SetCfgValue(IConfiguration cfg, ITriggerer trigger) { if (trigger.Text.HasNext) { var name = trigger.Text.NextWord(); var value = trigger.Text.Remainder; if (value.Length == 0) { trigger.Reply("No arguments given."); return(false); } if (cfg.Contains(name)) { //if (def.MaySet(trigger.Args.Role)) if (cfg.Set(name, value)) { trigger.Reply("Variable \"{0}\" is now set to: " + value, name); return(true); } else { trigger.Reply("Unable to set Variable \"{0}\" to value: {1}.", name, value); } //else //{ // trigger.Reply("You do not have enough privileges to set Variable \"{0}\".", def.Name); //} } else { trigger.Reply("Variable \"{0}\" does not exist.", name); } } return(false); }
public static bool GetCfgValue(IConfiguration cfg, ITriggerer trigger) { if (trigger.Text.HasNext) { var name = trigger.Text.NextWord(); //if (def.MaySet(trigger.Args.Role)) var val = cfg.Get(name); if (val != null) { trigger.Reply("Variable {0} = {1}", name, Utility.GetStringRepresentation(val)); return true; } trigger.Reply("Variable \"{0}\" does not exist.", name); //else //{ // trigger.Reply("You do not have enough privileges to set Variable \"{0}\".", def.Name); //} return true; } trigger.Reply("No arguments given."); return false; }
public static void ListCfgValues(IConfiguration cfg, ITriggerer trigger) { var vars = new List<IVariableDefinition>(50); var filter = trigger.Text.Remainder; if (filter.Length > 0) { cfg.Foreach((def) => { if (def.Name.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) >= 0) { vars.Add(def); } }); if (vars.Count == 0) { trigger.Reply("Could not find any globals that contain \"{0}\". - Do you have sufficient rights?", filter); } } else { cfg.Foreach(vars.Add); if (vars.Count == 0) { trigger.Reply("No variables found."); } } if (vars.Count > 0) { vars.Sort(); trigger.Reply("Found {0} globals:", vars.Count); foreach (var var in vars) { trigger.Reply(var.Name + " = " + var.GetFormattedValue()); } } }