private void Lib_OnClientMoved(object sender, IEnumerable <ClientMoved> e) { if (!Enabled) { return; } foreach (var client in e) { if (lib.WhoAmI().ChannelId == client.TargetChannelId) { continue; } var clientinfo = lib.ClientInfo(client.ClientId); if (!clientUIDs.Contains(clientinfo.Uid)) { continue; } if (!clientinfo.ServerGroups.Contains(Convert.ToUInt64(13))) { continue; } var welcomemsg = welcomeMSG.Replace("{nickname}", clientinfo.NickName).Replace("{uid}", clientinfo.Uid); PluginLog(Log.Level.Debug, "\n" + welcomemsg + "\n"); bot.QueryConnection.SendMessage(welcomemsg, client.ClientId); clientUIDs.Add(clientinfo.Uid); } }
public static IOrderedEnumerable <ClientInfo> ListUsers(this Ts3FullClient client) { var clientList = client.ClientList(); if (clientList.Ok) { return(clientList .Unwrap() .Where(x => x.ClientType != ClientType.Query) .Select(x => client.ClientInfo(x.ClientId)) .Where(x => x.Ok) .Select(x => x.Unwrap()) .OrderBy(x => x.ChannelId)); } else { return(Enumerable.Empty <ClientInfo>() .OrderBy(x => x)); } }
public R <ClientInfo, LocalStr> GetClientInfoById(ushort id) => tsFullClient.ClientInfo(id).FormatLocal(() => strings.error_ts_no_client_found);
public string checkClient(ClientIdT clid, string ip = "") { var _client = lib.ClientInfo(clid); if (clid == lib.ClientId || _client.ClientType == TS3Client.ClientType.Query || whitelistUID.Contains(_client.Uid) || whitelistSGID.Intersect(_client.ServerGroups).Any()) { return("self or query or whitelisted"); } var client = new Client(); if (String.IsNullOrWhiteSpace(ip)) { ip = _client.Ip; } ip = ip.Replace("[", "").Replace("]", ""); var isIP = IPAddress.TryParse(_client.Ip, out client.Ip); if (!isIP) { PluginLog(Log.Level.Error, $"Unable to get ip of \"{_client.NickName}\" #{clid} (dbid:{_client.DatabaseId}). Make sure the bot has the b_client_remoteaddress_view permission!"); return("unresolvable"); } if (allowed.Contains(ip) || IsLocal(ip)) { return("already allowed or local"); } client.Id = clid; client.NickName = _client.NickName; client.Uid = _client.Uid; client.CountryCode = _client.CountryCode; if (blocked.Contains(ip)) { takeAction(client, "Actions", true); return("already blocked"); } client.Isp = getISP(ip, cfg["API"]["main"]).Replace($"\n", "").Replace($"\r", ""); if (cfg["General"]["learn"] == "true") { var m = "unknown"; if (client.Isp != "unknown") { m = learn(client.Isp); } var fb = getISP(client.Ip.ToString(), cfg["API"]["fallback"]).Replace($"\n", "").Replace($"\r", "");; var f = "unknown"; if (client.Isp != "unknown") { f = learn(fb); } var fb2 = getISP(client.Ip.ToString(), cfg["API"]["fallback2"]).Replace($"\n", "").Replace($"\r", "");; var f2 = "unknown"; if (client.Isp != "unknown") { f2 = learn(fb2); } return($"main ({client.Isp}): {m} | fallback ({fb}): {f} | fallback2 ({fb2}): {f2}"); } else { if (client.Isp == "unknown") { client.Isp = getISP(ip, cfg["API"]["fallback"]).Replace($"\n", ""); if (client.Isp == "unknown") { client.Isp = getISP(ip, cfg["API"]["fallback2"]).Replace($"\n", ""); } } } PluginLog(Log.Level.Debug, $"Got ISP \"{client.Isp}\" for client \"{client.NickName}\" #{client.Id} (dbid:{_client.DatabaseId})"); if (client.Isp.ToLower() == "unknown" || client.Isp.ToLower() == "undefined") { if (cfg["Unresolvable"]["enabled"] == "true" && cfg["General"]["learn"] != "true") { takeAction(client, "Unresolvable"); } return("unknown or undefined"); } return(checkISP(client).ToString()); }