Ts3audiobot: [Client related] FileTransfer question

Created on 6 May 2018  路  3Comments  路  Source: Splamy/TS3AudioBot

Hey,
I wanted to ask if there is a possibility to get all the server icons? Or at least icons assigned to groups?

Thanks.

question

Most helpful comment

Something like this should do the trick:

// use this if you want to list all icon files
//var folder = client.FileTransferGetFileList(0, "/icons").Unwrap();

var resultGroupList = client.SendNotifyCommand(new TS3Client.Commands.Ts3Command("servergrouplist"), NotificationType.ServerGroupList).Unwrap();
foreach (var group in resultGroupList.Notifications.Cast<ServerGroupList>())
{
    var icon = group.IconId;
    string fileName = "icon_" + icon;
    using (var fs = new FileInfo(fileName).Open(FileMode.OpenOrCreate, FileAccess.ReadWrite))
    {
        var resultDl = client.FileTransferManager.DownloadFile(fs, 0, "/" + fileName);
        if (resultDl.Ok)
        {
            var token = resultDl.Value;
            token.Wait();
        }
    }
}

Note that this code uses a few Unwraps from my error handling class, so if you get errors you should instead handle them correctly (as in the last part).

The preinstalled ts3 icons are not in the /icons folder and cannot be downloaded (usually have an id like 0, 100, 200, etc)

All 3 comments

Something like this should do the trick:

// use this if you want to list all icon files
//var folder = client.FileTransferGetFileList(0, "/icons").Unwrap();

var resultGroupList = client.SendNotifyCommand(new TS3Client.Commands.Ts3Command("servergrouplist"), NotificationType.ServerGroupList).Unwrap();
foreach (var group in resultGroupList.Notifications.Cast<ServerGroupList>())
{
    var icon = group.IconId;
    string fileName = "icon_" + icon;
    using (var fs = new FileInfo(fileName).Open(FileMode.OpenOrCreate, FileAccess.ReadWrite))
    {
        var resultDl = client.FileTransferManager.DownloadFile(fs, 0, "/" + fileName);
        if (resultDl.Ok)
        {
            var token = resultDl.Value;
            token.Wait();
        }
    }
}

Note that this code uses a few Unwraps from my error handling class, so if you get errors you should instead handle them correctly (as in the last part).

The preinstalled ts3 icons are not in the /icons folder and cannot be downloaded (usually have an id like 0, 100, 200, etc)

Actually some of my icons have id higher than integer's max value. Could you change it to (u)long in your lib?

This should be by design because teamspeak is stupid. They are calculating the crc32 which gives a int as hash output, but they sometimes send it as long, so to get the correct icon hash you have to take value % int.MaxValue, which is what we are already doing when receiving a icon field IconId = unchecked((int)long.Parse(value.NewString(), CultureInfo.InvariantCulture));

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bluscream picture Bluscream  路  6Comments

lgund picture lgund  路  6Comments

Thomseeen picture Thomseeen  路  5Comments

luzzbe picture luzzbe  路  6Comments

GooG2e picture GooG2e  路  8Comments