internal bool SetupRights(string key) { var dbResult = tsFullClient.GetClientDbIdFromUid(identity.ClientUid); if (!dbResult.Ok) { Log.Error("Getting own dbid failed ({0})", dbResult.Error.ErrorFormat()); return(false); } var myDbId = dbResult.Value.ClientDbId; // Check all own server groups var getGroupResult = GetClientServerGroups(myDbId); var groups = getGroupResult.Ok ? getGroupResult.Value : Array.Empty <ulong>(); // Add self to master group (via token) if (!string.IsNullOrEmpty(key)) { var privKeyUseResult = tsFullClient.PrivilegeKeyUse(key); if (!privKeyUseResult.Ok) { Log.Error("Using privilege key failed ({0})", privKeyUseResult.Error.ErrorFormat()); return(false); } } // Remember new group (or check if in new group at all) var groupDiff = Array.Empty <ulong>(); if (getGroupResult.Ok) { getGroupResult = GetClientServerGroups(myDbId); var groupsNew = getGroupResult.Ok ? getGroupResult.Value : Array.Empty <ulong>(); groupDiff = groupsNew.Except(groups).ToArray(); } if (config.BotGroupId == 0) { // Create new Bot group var botGroup = tsFullClient.ServerGroupAdd("ServerBot"); if (botGroup.Ok) { config.BotGroupId.Value = botGroup.Value.ServerGroupId; // Add self to new group var grpresult = tsFullClient.ServerGroupAddClient(botGroup.Value.ServerGroupId, myDbId); if (!grpresult.Ok) { Log.Error("Adding group failed ({0})", grpresult.Error.ErrorFormat()); } } } const int max = 75; const int ava = 500000; // max size in bytes for the avatar // Add various rights to the bot group var permresult = tsFullClient.ServerGroupAddPerm(config.BotGroupId.Value, new[] { Ts3Permission.i_client_whisper_power, // + Required for whisper channel playing Ts3Permission.i_client_private_textmessage_power, // + Communication Ts3Permission.b_client_server_textmessage_send, // + Communication Ts3Permission.b_client_channel_textmessage_send, // + Communication Ts3Permission.b_client_modify_dbproperties, // ? Dont know but seems also required for the next one Ts3Permission.b_client_modify_description, // + Used to change the description of our bot Ts3Permission.b_client_info_view, // (+) only used as fallback usually Ts3Permission.b_virtualserver_client_list, // ? Dont know but seems also required for the next one Ts3Permission.i_channel_subscribe_power, // + Required to find user to communicate Ts3Permission.b_virtualserver_client_dbinfo, // + Required to get basic user information for history, api, etc... Ts3Permission.i_client_talk_power, // + Required for normal channel playing Ts3Permission.b_client_modify_own_description, // ? not sure if this makes b_client_modify_description superfluous Ts3Permission.b_group_is_permanent, // + Group should stay even if bot disconnects Ts3Permission.i_client_kick_from_channel_power, // + Optional for kicking Ts3Permission.i_client_kick_from_server_power, // + Optional for kicking Ts3Permission.i_client_max_clones_uid, // + In case that bot times out and tries to join again Ts3Permission.b_client_ignore_antiflood, // + The bot should be resistent to forced spam attacks Ts3Permission.b_channel_join_ignore_password, // + The noble bot will not abuse this power Ts3Permission.b_channel_join_permanent, // + Allow joining to all channel even on strict servers Ts3Permission.b_channel_join_semi_permanent, // + Allow joining to all channel even on strict servers Ts3Permission.b_channel_join_temporary, // + Allow joining to all channel even on strict servers Ts3Permission.b_channel_join_ignore_maxclients, // + Allow joining full channels Ts3Permission.i_channel_join_power, // + Allow joining to all channel even on strict servers Ts3Permission.b_client_permissionoverview_view, // + Scanning through given perms for rights system Ts3Permission.i_client_max_avatar_filesize, // + Uploading thumbnails as avatar Ts3Permission.b_client_use_channel_commander, // + Enable channel commander Ts3Permission.b_client_ignore_bans, // + The bot should be resistent to bans Ts3Permission.b_client_ignore_sticky, // + Should skip weird movement restrictions }, new[] { max, max, 1, 1, 1, 1, 1, 1, max, 1, max, 1, 1, max, max, 4, 1, 1, 1, 1, 1, 1, max, 1, ava, 1, 1, 1, }, new[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, }, new[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, }); if (!permresult) { Log.Error("Adding permissions failed ({0})", permresult.Error.ErrorFormat()); } // Leave master group again if (groupDiff.Length > 0) { foreach (var grp in groupDiff) { var grpresult = tsFullClient.ServerGroupDelClient(grp, myDbId); if (!grpresult.Ok) { Log.Error("Removing group failed ({0})", grpresult.Error.ErrorFormat()); } } } return(true); }