public void SendMessage(string clientNickname, uint clId, string input = null) { _helloCount++; Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"Hello {clientNickname}. You greeted me for the {_helloCount}. time. {(input != null ? "You just said: " + input : "")}"); var channel = Ts3Instance.GetChannelInfo(20633); Console.WriteLine("PARENT ID:" + channel.ParentChannelId); }
public void Rename(uint clId, string name, MessageTarget target) { var response = Ts3Instance.UpdateCurrentQueryClient(new ClientModification { Nickname = name }); if (!response.IsErroneous) { Ts3Instance.SendTextMessage(target, clId, $"Changed name to {name}"); } }
public void GetConfig(uint clId, string key) { var value = GetConfigValue(key); if (value == null) { Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"{key} is not in the config!"); return; } Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"{key}'s value is {value}"); }
public void ListPlugins(string uniqueId, uint clId, MessageTarget target) { var clientDatabaseId = Ts3Instance .GetClientNameAndDatabaseIdByUniqueId(uniqueId).ClientDatabaseId; if (clientDatabaseId != null) { var groups = Ts3Instance.GetServerGroupsByClientId((uint)clientDatabaseId).Select(x => x.Name); var commands = PluginManager.CommandList.Where(x => x.ServerGroups.Groups.Length == 0 || (x.ServerGroups?.Groups.Intersect(groups).Any()).Value).ToArray(); if (commands.Any()) { Ts3Instance.SendTextMessage(target, clId, "Available commands: " + string.Join(", ", commands.OrderBy(x => x.Command.CommandName).Select(x => "!" + x.Command.CommandName))); } else { Ts3Instance.SendTextMessage(target, clId, "You have no commands available!"); } } }
public void Info(uint clId, MessageTarget target, MessageReceivedEventArgs eventArgs, string command) { var clientDatabaseId = Ts3Instance .GetClientNameAndDatabaseIdByUniqueId(eventArgs.InvokerUniqueId).ClientDatabaseId; if (!clientDatabaseId.HasValue) { Ts3Instance.SendTextMessage(target, clId, "Error, please contact administrator!"); return; } var serverGroups = Ts3Instance.GetServerGroupsByClientId((uint)clientDatabaseId).Select(x => x.Name); var commands = Manager.CommandList.Where(x => x.Command.CommandName.StartsWith(command, StringComparison.OrdinalIgnoreCase) && (x.ServerGroups.Groups.Intersect(serverGroups).Any() || !x.ServerGroups.Groups.Any())).ToArray(); if (commands.Length > 0) { var toWrite = "Available commands:" + Environment.NewLine; foreach (var methodInfo in commands.Select(x => x.Method)) { var clientCommands = (ClientCommand[])methodInfo.GetCustomAttributes(typeof(ClientCommand), false); var parameters = methodInfo.GetParameters().Where(x => x.ParameterType == typeof(string)).ToArray(); var stringParameters = string.Empty; foreach (var parameterInfo in parameters) { if (parameterInfo.HasDefaultValue) { var defaultValue = (string)parameterInfo.DefaultValue ?? "?"; var regex = Regex.Match(defaultValue, "^(?<optional>\\?)?(?:{(?=.+})(?<name>.+?)})?(?<parameters>.*)?", RegexOptions.IgnoreCase); var optional = regex.Groups["optional"].Value == "?"; if (regex.Groups["name"].Value != string.Empty) { stringParameters += regex.Groups["name"].Value; } else if (regex.Groups["parameters"].Value != string.Empty) { var allowedValues = new[] { regex.Groups["parameters"].Value }; if (allowedValues[0].Contains('|')) { allowedValues = allowedValues[0].Split('|'); } stringParameters += $"< {(optional ? "[I]" : "")}{string.Join(" / ", allowedValues)}{(optional ? "[/I]" : "")} >"; } else { stringParameters += $"{(optional ? "[I]" : "")}{parameterInfo.Name}{(optional ? "[/I]" : "")}"; } } if (!parameterInfo.HasDefaultValue && parameterInfo.Name != "uniqueid" && parameterInfo.Name != "clientnickname") { stringParameters += parameterInfo.Name; } stringParameters += " "; } if (parameters.Length == 0) { stringParameters += " "; } var descriptions = clientCommands.Select(x => x.CommandInfo).Where(x => x != null).ToArray(); if (descriptions.Length < 2) { toWrite += $"{string.Join(", ", clientCommands.Select(x => "[B]!" + x.CommandName + "[/B]"))} " + $"{stringParameters}" + $"- {(descriptions.Length == 1 ? descriptions[0] : "[I]Without description[/I]")}{Environment.NewLine}"; } else { toWrite += $"{string.Join(", ", clientCommands.Select(x => "[B]!" + x.CommandName + "[/B]"))} " + $"{stringParameters}" + $"- {string.Join(", ", descriptions)}{Environment.NewLine}"; } } Ts3Instance.SendTextMessage(target, clId, toWrite); } else { Ts3Instance.SendTextMessage(target, clId, $"No commands found starting with \"{command}\""); } }
public void Uptime(uint clId) { Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"Been running for {DateTime.Now - Process.GetCurrentProcess().StartTime}"); }
public void SetConfig(uint clId, string key, string value) { SetConfigValue(key, value); Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"{key}'s value is {(string)GetConfigValue(key)}"); }
public void UnloadPlugin(uint clId, string plugin = "{\"Name of plugin\"}") { var successfulRemoval = PluginManager.UnloadPlugin(plugin, out var unloadedPlugins); Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"{(successfulRemoval ? "Successfully" : "Unsuccessfully")} removed plugin(s) {unloadedPlugins}."); }
public void ReloadPlugin(uint clId, string plugin = "{\"Name of plugin\"}") { var success = PluginManager.ReloadPlugin(plugin); Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"I have {(success ? "successfully" : "failed to ")} reloaded plugin {plugin}"); }
public void LoadPlugin(uint clId, string plugin = "{\"Absolute path to plugin\"}") { var plugins = PluginManager.LoadDll(plugin); Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"I have loaded {(plugins.Count > 0 ? string.Join(", ", plugins.Select(x => x.GetType().Name)) : "no plugins, please check console")}"); }
public void ListPlugins(uint clId) { Ts3Instance.SendTextMessage(MessageTarget.Client, clId, $"I have currently loaded {PluginManager.PluginsCount()} plugin(s). {PluginManager.GetPluginList()}"); }
private void SendResponse(MessageTarget target, uint clid, string message) { Ts3Instance.SendTextMessage(target, clid, message); }