public static Teamspeak3Request BuildServerCreate(String name) { var tsServerCreate = new Teamspeak3Request("servercreate"); tsServerCreate.AddParameter("virtualserver_name", name); return tsServerCreate; }
public static Teamspeak3Request BuildLogin(String username, String password) { var tsLogin = new Teamspeak3Request("login"); tsLogin.AddParameter("client_login_name", username); tsLogin.AddParameter("client_login_password", password); return tsLogin; }
public static Teamspeak3Request BuildSendTextMessage(Teamspeak3.Objects.TextMessageTarget target, Int32 targetId, String message) { var tsSendTextMessage = new Teamspeak3Request("sendtextmessage"); tsSendTextMessage.AddParameter("targetmode", ((Int32)target).ToString()); tsSendTextMessage.AddParameter("target", targetId.ToString()); tsSendTextMessage.AddParameter("msg", message); return tsSendTextMessage; }
public static Teamspeak3Request BuildBanClient(Int32 clientId, String message, Int32? seconds = null) { var tsBanClient = new Teamspeak3Request("banclient"); tsBanClient.AddParameter("clid", clientId.ToString()); tsBanClient.AddParameter("banreason", message); if (seconds.HasValue) tsBanClient.AddParameter("time", seconds.ToString()); return tsBanClient; }
public static Teamspeak3Request BuildGlobalMessage(String message) { var tsGlobalMessage = new Teamspeak3Request("gm"); tsGlobalMessage.AddParameter("msg", message); return tsGlobalMessage; }
public static Teamspeak3Request BuildServerStop(Int32 serverId) { var tsServerStop = new Teamspeak3Request("serverstop"); tsServerStop.AddParameter("sid", serverId.ToString()); return tsServerStop; }
public static Teamspeak3Request BuildUsePort(Int32 port) { var tsUsePort = new Teamspeak3Request("use"); tsUsePort.AddParameter("port", port.ToString()); return tsUsePort; }
public static Teamspeak3Request BuildClientFind(String name) { var tsClientFind = new Teamspeak3Request("clientfind"); tsClientFind.AddParameter("pattern", name); return tsClientFind; }
public static Teamspeak3Request BuildClientInfo(Int32 clientId) { var tsClientInfo = new Teamspeak3Request("clientinfo"); tsClientInfo.AddParameter("clid", clientId.ToString()); return tsClientInfo; }
public static Teamspeak3Request BuildChannelInfo(Int32 channelId) { var tsChannelInfo = new Teamspeak3Request("channelinfo"); tsChannelInfo.AddParameter("cid", channelId.ToString()); return tsChannelInfo; }
public static Teamspeak3Request BuildChannelMove(Int32 channelId, Int32 parentId, Int32? order = null) { var tsChannelMove = new Teamspeak3Request("channelmove"); tsChannelMove.AddParameter("cid", channelId.ToString()); tsChannelMove.AddParameter("cpid", parentId.ToString()); if (order.HasValue) tsChannelMove.AddParameter("order", order.ToString()); return tsChannelMove; }
public static Teamspeak3Request BuildChannelDelete(Int32 channelId, Boolean force = false) { var tsChannelDelete = new Teamspeak3Request("channeldelete"); tsChannelDelete.AddParameter("cid", channelId.ToString()); tsChannelDelete.AddParameter("force", (force) ? "1" : "0"); return tsChannelDelete; }
public static Teamspeak3Request BuildChannelCreate(String name, Int32? parentId = null, Int32? order = null) { var tsChannelCreate = new Teamspeak3Request("channelcreate"); tsChannelCreate.AddParameter("channel_name", name); if (parentId.HasValue) tsChannelCreate.AddParameter("cpid", parentId.ToString()); if (order.HasValue) tsChannelCreate.AddParameter("channel_order", order.ToString()); return tsChannelCreate; }
public static Teamspeak3Request BuildBanDel(Int32 banId) { var tsBuildBanDel = new Teamspeak3Request("bandel"); tsBuildBanDel.AddParameter("banid", banId.ToString()); return tsBuildBanDel; }
public static Teamspeak3Request BuildServerDelete(Int32 serverId) { var tsServerDelete = new Teamspeak3Request("serverdelete"); tsServerDelete.AddParameter("sid", serverId.ToString()); return tsServerDelete; }
public static Teamspeak3Request BuildClientKick(Int32 clientId, Teamspeak3.Objects.KickMode type, String message = null) { var tsClientKick = new Teamspeak3Request("clientkick"); tsClientKick.AddParameter("clid", clientId.ToString()); tsClientKick.AddParameter("reasonid", ((Int32)type).ToString()); if (!String.IsNullOrWhiteSpace(message)) tsClientKick.AddParameter("reasonmsg", message); return tsClientKick; }
public static Teamspeak3Request BuildServerGetId(Int32 port) { var tsServerGetId = new Teamspeak3Request("serveridgetbyport"); tsServerGetId.AddParameter("virtualserver_port", port.ToString()); return tsServerGetId; }
public static Teamspeak3Request BuildClientMove(Int32 clientId, Int32 channelId) { var tsClientMove = new Teamspeak3Request("clientmove"); tsClientMove.AddParameter("clid", clientId.ToString()); tsClientMove.AddParameter("cid", channelId.ToString()); return tsClientMove; }
public static Teamspeak3Request BuildUseId(Int32 serverId) { var tsUseId = new Teamspeak3Request("use"); tsUseId.AddParameter("sid", serverId.ToString()); return tsUseId; }
public static Teamspeak3Request BuildClientPoke(Int32 clientId, String message) { var tsClientPoke = new Teamspeak3Request("clientpoke"); tsClientPoke.AddParameter("clid", clientId.ToString()); tsClientPoke.AddParameter("msg", message); return tsClientPoke; }
public static Teamspeak3Request BuildBanAddName(String name, String message, Int32? seconds = null) { var tsBuildBanAddIp = new Teamspeak3Request("banadd"); tsBuildBanAddIp.AddParameter("name", name); tsBuildBanAddIp.AddParameter("banreason", message); if (seconds.HasValue) tsBuildBanAddIp.AddParameter("time", seconds.ToString()); return tsBuildBanAddIp; }
static void Main() { // Uses the default settings: // - Timeout from trying to connect after 10 seconds. var tConnection = new Teamspeak3Connection(); tConnection.Connected += (c) => Console.WriteLine("[Status] Connected!"); tConnection.Disconnected += (c) => Console.WriteLine("[Status] Disconnected!"); tConnection.SentRequest += (c, r) => Console.WriteLine("[Query] Request Sent: {0}", r.Command); tConnection.ReceivedResponse += (c, r) => Console.WriteLine("[Query] Response Received: {0}", r.Id); tConnection.Notified += (c, n) => Console.WriteLine("[Notification] Seen {0}", n.Event); tConnection.Banned += (c, r) => Console.WriteLine("[Banned] Crap: {0} -- {1}", r.Message, r.ExtraMessage); // Attempt to connect to the server at 127.0.0.1:10011. tConnection.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10011)); // Select the virtual server to use and login. tConnection.Send(Teamspeak3Request.BuildLogin("serveradmin", "password")); tConnection.Send(Teamspeak3Request.BuildUsePort(9987)); // Request the client list from the server and parse the response into clients. var tClientMessage = tConnection.Send(Teamspeak3Request.BuildClientList()); var tClients = tClientMessage.Sections .SelectMany(x => x.Groups) .Select(x => new Teamspeak3Client(x)) .ToList(); // Requeust the channel list from the server and parse the response into channels. var tChannelMessage = tConnection.Send(Teamspeak3Request.BuildClientList()); var tChannels = tChannelMessage.Sections .SelectMany(x => x.Groups) .Select(x => new Teamspeak3Channel(x)) .ToList(); // Register for notifications when clients join/leave the server. var tNotificationRequest = new Teamspeak3Request("servernotifyregister"); tNotificationRequest.AddParameter("event","server"); tConnection.Send(tNotificationRequest); // Example request with error checking. var tResponse = tConnection.Send(Teamspeak3Request.BuildWhoAmI()); if (tResponse == null) { // The connection is closed or had an error? Console.WriteLine("Connection Failure!"); } else if (tResponse.Id == 3331 || tResponse.Id == 3329) { // Yarg, we've been banned due to spamming! Console.WriteLine("Banned: {0} -- {1}", tResponse.Message, tResponse.ExtraMessage); } else if (tResponse.Id != 0) { // Ahhhh, what went wrong? Console.WriteLine("Error: {0}", tResponse.Message); } tConnection.Send(Teamspeak3Request.BuildLogout()); tConnection.Send(Teamspeak3Request.BuildQuit()); tConnection.Send(Teamspeak3Request.BuildWhoAmI()); Console.ReadKey(); tConnection.Dispose(); }