TS3AudioBot
TS3AudioBot copied to clipboard
WebApi: Last error
Is your feature request related to a problem? Please describe. Repro:
- Create a bot and connect it to a server
# create bot
curl -s http://127.0.0.1:58913/api/settings/create/test
curl -s http://127.0.0.1:58913/api/settings/bot/set/test/connect.address/127.0.0.1
curl -s http://127.0.0.1:58913/api/bot/connect/template/test
- Ban the bot
- Try to find out why the bot is not connected through the API:
# try to get the bot to connect
λ curl -s http://127.0.0.1:58913/api/bot/connect/template/test | jq
{
"Id": 0,
"Name": "test",
"Server": "127.0.0.1",
"Status": 1
}
# get the bot info
λ curl -s http://127.0.0.1:58913/api/bot/template/test/(/bot/info) | jq
{
"Id": 0,
"Name": "test",
"Server": "127.0.0.1",
"Status": 1
}
- You only get
Status: 1(bot is connecting) until depending on yourReconnect strategyit stops, then bot info just says"This bot does not exist."
Describe the solution you'd like
- Add an extra Status code for Reconnecting in addition to Disconnected, Connecting, Connected.
- Add an extra field
LastErrorin/bot/info's output with the text message of why the bot failed to connect. (e.g. TimedOut, Banned, ...) - Add a method to access the last
nlines of log for a certain template. - Store the last connect attempt's date/result in the bot's template (So we could find out why it failed even if the Reconnect strategy is set to 0 tries and it immediately stops trying)
Describe alternatives you've considered The failure is explained in the logs:
18:46:31.4523| INFO|| ::ffff:127.0.0.1 Requested: /api/bot/connect/template/test
18:46:31.4963| INFO|| Bot "test" connecting to "127.0.0.1"
18:46:31.7023| WARN|0| Dropping not decryptable packet: 54 53 33 49 4E 49 54 31 00 00 A6 00 01
18:46:31.7233| WARN|0| This bot is banned.
18:46:31.7233| INFO|0| Reconnect strategy for 'Ban' has reached the end. Closing instance.
18:46:31.7233| INFO|0| Bot (0) disconnecting.
So manual inspection is possible. However, I feel writing a parser for log output to detect why a certain template failed to connect is very error-prone and hack-ish.
Definitely planned because I wanted something like that too.