public void Login() { var login = _serverQueryClient.Login(QueryUserName, QueryPassword).Result; Console.WriteLine("login {0} {1} {2}", login.Success, login.ErrorId, login.ErrorMessage); ServerQueryBaseResult use = _serverQueryClient.Use(UseServerBy.ServerId, 1).Result; Console.WriteLine("use {0} {1} {2}", use.Success, use.ErrorId, use.ErrorMessage); _serverQueryClient.KeepAlive(TimeSpan.FromMinutes(2)); var registerTextChannel = _serverQueryClient.ServerNotifyRegister(Event.server).Result; Console.WriteLine("registerTextChannel {0} {1} {2}", registerTextChannel.Success, registerTextChannel.ErrorId, registerTextChannel.ErrorMessage); _serverQueryClient.NotifyServerEdited += (sender, result) => { Console.WriteLine("HOAL!"); }; var clientList = _serverQueryClient.ClientList().Result; Console.WriteLine("clientList {0} {1} [x{2}]", clientList.Success, clientList.ErrorId, clientList.Values?.Count ?? 0); }
public bool Start() { client = new ServerQueryClient(Url, 10011, TimeSpan.FromSeconds(3)); try { ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { ServerQueryBaseResult login = client.Login(Login, Password).Result; if (login.Success) { ServerQueryBaseResult use = client.Use(UseServerBy.Port, 9987).Result; if (use.Success) { return(true); } } } } catch (Exception ex) { } return(false); }
public bool Start() { client = new ServerQueryClient(Url, 10011, TimeSpan.FromSeconds(3)); try { ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { ServerQueryBaseResult login = client.Login(Login, Password).Result; if (login.Success) { ServerQueryBaseResult use = client.Use(UseServerBy.Port, 9987).Result; if (use.Success) { return true; } } } } catch (Exception ex) { } return false; }
public async Task <bool> AddClient(string name, string groupName, string TSURL, string password) { client = new ServerQueryClient(TSURL, 10011, TimeSpan.FromSeconds(3)); try { ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { ServerQueryBaseResult login = client.Login("serveradmin", password).Result; if (login.Success) { ServerQueryBaseResult use = client.Use(UseServerBy.Port, 9987).Result; if (use.Success) { client.KeepAlive(TimeSpan.FromMinutes(2)); clientList = client.ClientList().Result; ClientInfoResult ClientInfo = clientList.Values.Where(m => m.ClientNickname == name).FirstOrDefault(); if (ClientInfo != null) { await GetDBID(ClientInfo.ClientUniqueIdentifier); await GetServerGroup(groupName); await AddClient(); Message = string.Format("User {0} successfully created on TS Server {1}.", name, TSURL); } else { SuccessType = AddSuccess.Fail; Message = string.Format("Could not find a valid user on {0}. Please make sure your nickname is {1} and try again.", TSURL, name); } } } } } catch (Exception ex) { SuccessType = AddSuccess.Fail; } finally { ServerQueryBaseResult unregister = client.ServerNotifyUnregister().Result; ServerQueryBaseResult logout = client.Logout().Result; ServerQueryBaseResult quit = client.Quit().Result; } return(true); }
public async Task<bool> AddClient(string name, string groupName, string TSURL, string password) { client = new ServerQueryClient(TSURL, 10011, TimeSpan.FromSeconds(3)); try { ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { ServerQueryBaseResult login = client.Login("serveradmin", password).Result; if (login.Success) { ServerQueryBaseResult use = client.Use(UseServerBy.Port, 9987).Result; if (use.Success) { client.KeepAlive(TimeSpan.FromMinutes(2)); clientList = client.ClientList().Result; ClientInfoResult ClientInfo = clientList.Values.Where(m => m.ClientNickname == name).FirstOrDefault(); if (ClientInfo != null) { await GetDBID(ClientInfo.ClientUniqueIdentifier); await GetServerGroup(groupName); await AddClient(); Message = string.Format("User {0} successfully created on TS Server {1}.", name, TSURL); } else { SuccessType = AddSuccess.Fail; Message = string.Format("Could not find a valid user on {0}. Please make sure your nickname is {1} and try again.", TSURL, name); } } } } } catch (Exception ex) { SuccessType = AddSuccess.Fail; } finally { ServerQueryBaseResult unregister = client.ServerNotifyUnregister().Result; ServerQueryBaseResult logout = client.Logout().Result; ServerQueryBaseResult quit = client.Quit().Result; } return true; }
public static void TeamSpeak(string param, Dictionary <string, CommandRecord> commandMap) { var TSclient = new ServerQueryClient("127.0.0.1", 10011, TimeSpan.Zero); TSclient.ConnectionClosed += (sender, eventArgs) => Logger.Write(":sadface:", LogLevel.Error); var init = TSclient.Initialize().Result; if (!init.Success) { Logger.Write($"TeamSpeak: {init.ErrorMessage}"); return; } var login = TSclient.Login("serveradmin", "CrneScCM").Result; if (!login.Success) { Logger.Write($"TeamSpeak: {login.ErrorMessage}"); return; } var use = TSclient.Use(UseServerBy.ServerId, 1).Result; if (!use.Success) { Logger.Write($"TeamSpeak: {use.ErrorMessage}"); return; } var clientList = TSclient.ClientList().Result; if (clientList.Success) { foreach (var client in clientList.Values) { if (!client.ClientNickname.Contains("serveradmin ")) { Logger.Write($"{client.ClientNickname}", LogLevel.Info); } } } Console.WriteLine("---"); }
public static void ConnectQueryAsync() { ServerQueryClient client = new ServerQueryClient(host, port, TimeSpan.FromSeconds(1)); ServerQueryBaseResult connected = client.Initialize().Result; if (connected.Success) { MessageBox.Show("connected"); } ServerQueryBaseResult login = client.Login(user, password).Result; if (!login.Success) { MessageBox.Show(login.ErrorMessage); } ServerQueryBaseResult use = client.Use(UseServerBy.Port, 10677).Result; if (!use.Success) { MessageBox.Show(use.ErrorMessage); } //client.SendTextMessage(TextMessageTargetMode.TextMessageTarget_CLIENT, 3, "please respond"); ClientListResult clientList = client.ClientList().Result; if (!clientList.Success) { MessageBox.Show(clientList.ErrorMessage); } client.NotifyTextMessage += (source, notification) => MessageBox.Show(notification.Invokername + ": " + notification.Msg); ServerQueryBaseResult registerTextChannel = client.ServerNotifyRegister(Event.textprivate).Result; if (!registerTextChannel.Success) { MessageBox.Show(registerTextChannel.ErrorMessage); } client.KeepAlive(TimeSpan.FromMinutes(10)); client.NotifyChannelEdited += (source, notification) => MessageBox.Show(notification.Invokername + ": " + notification.Invokerid); for (int i = 0; i < clientList.Values.Count; i++) { ClientInfoResult clientInfoResult = clientList.Values[i]; int id = clientInfoResult.ClientId; String name = clientInfoResult.ClientNickname; if (!name.Contains("Sharix")) { client.SendTextMessage(TextMessageTargetMode.TextMessageTarget_CLIENT, id, "you are a nonce lol"); MessageBox.Show(id.ToString() + " " + name); } } }
static void Use() { ServerQueryBaseResult use = client.Use(UseServerBy.Port, int.Parse(cfg["server"]["voiceport"])).Result; Console.WriteLine("use {0} {1} {2}", use.Success, use.ErrorId, use.ErrorMessage); }