Tsbot

Latest version: v1.6.1

Safety actively analyzes 701786 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

1.6.1

What's Changed

Response getters
You can now access first point of data from the respose objects straight away.
You can subscribe to response objects (`response[<some key>]`) or use `response.get(<some key>, <optional default>)` getter.

python
client = bot.send(query("clientfind").params(pattern="sven))
svens_client_id = client["id"]


PR: 73

Update `TSResponsePermissionError` message
Message now tells more clearly that its a `permid`, not some vague `permission`

Commit: f549b02dfe269069d8a6aa5ed115b75af135c478

Fixes
* Once handlers having the same `has_run` context var. b9c0e6f96ec7761fe10dff6440e8284c20506c2f
* This would mean only one once handler would run. Ever.

**Full Changelog**: https://github.com/jykob/TSBot/compare/1.6.0...1.6.1

1.6.0

What's Changed

Batched queries
Some query commands allow you to target multiple actions at once.
This comes handy when for example moving multiple clients at once: `clientmove clid=1|clid=2 cid=3`.
But some commands don't allow you to do this.
`clientpoke` is a good example. You can only target one client at a time.

To poke all clients on the server, you would do something like this:
python
bot.command("poke", raw=True, help_text="pokes all clients with a message")
async def poke(bot: TSBot, ctx: TSCtx, message: str) -> None:
clients_list = await bot.send(query("clientlist"))
poke_query = query("clientpoke").params(msg=message)

await asyncio.gather(
*(bot.send(poke_query.params(clid=client["clid"])) for client in clients_list)
)


This would mean sending each query after another. Those queries would have to wait for a response.
If the bot instance is far away from the actual server from a networking perspective,
this would cause huge delays between each poke.

With `bot.send_batched()` method, you can refactor the poke command:
Poke all the clients on the server with a message with minimal network delay:
python
bot.command("poke", raw=True, help_text="pokes all clients with a message")
async def poke(bot: TSBot, ctx: TSCtx, message: str) -> None:
clients_list = await bot.send(query("clientlist"))
poke_query = query("clientpoke").params(msg=message)

await bot.send_batched(
poke_query.params(clid=client["clid"])
for client in clients_list
if client["client_type"] == "0"
)


PR: 69

---

Remove `ready` event
Completely remove deprecated `ready` event.
To migrate: change `ready` -> `connect`

PR: 71

---

Task object `.cancel()` method
You can now cancel background tasks from the object itself.

python
some_task = bot.register_task(some_task_handler)

Previously you would call bot.remove_task() to cancel
bot.remove_task(some_task)

Now you can cancel the task from the task object
some_task.cancel()


PR: 70

---

Debug query timings
Debug loggers now show how long each query took to execute.

Example log line:
`[DEBUG][20:07:13][tsbot] Query took 0.01268 seconds to execute`

PR: 68

Fixes
* Guarantee `bot.connected` is only set when bot is connected. 7182a7407eccc3a6055bb42009df201fc1bc477e
* Bot closing on connection error without trying to re-establish connection. 28fa501b798f48801a0d741417e7befd67e27385
* `TSEventOnceHandler` could run more than one time if event was emitted multiple times. 2cae0440afe3d661efce5c92b4441b6e616b200b
- This wouldn't run the actual handler, but raise `ValueError` when trying to remove the event.

**Full Changelog**: https://github.com/jykob/TSBot/compare/1.5.1...1.6.0

1.5.1

What's Changed
- Fix `run` event being ignored on run cbe83ce3bd4778e1b8e9a6e092f81ead16dd649b


**Full Changelog**: https://github.com/jykob/TSBot/compare/1.5.0...1.5.1

1.5.0

What's Changed

Task args
You can now pass args to tasks.
Arguments are positional only and type safe.

python
async def background_task(bot: TSBot, arg1: str, arg2: int) -> None:
print(arg1, arg2)
Some background task

bot.register_task(background_task, "test arg", 1)


Better typing support
Command handler overloads
Command handlers are just a little bit more type safe. For example, if you define a raw command handler and have more than 1 additional argument, your editor should yell at you.

Typed events and ctx overloads
Your editor should give smart suggestions about the `event_type` and their context types.
![Code_01oTqvaV7h](https://github.com/user-attachments/assets/9654cf04-d7f4-44c1-868f-967fb901b07d)

**Full Changelog**: https://github.com/jykob/TSBot/compare/1.4.1...1.5.0

1.4.1

What's Changed
Tasks exceptions
Before exceptions raised inside tasks would pass silently.

> Errors should never pass silently.
-- <cite>The Zen of Python</cite>

Tasks that exit with an exception will log the exception when TSBot cleans up the task
PR: 56

Better default ports
Raw connection type would require you to set port manually.
If you don't configure the port, TSBot will infer the port from the protocol.
PR: 57

**Full Changelog**: https://github.com/jykob/TSBot/compare/1.4.0...1.4.1

1.4.0

Features
Raw connections
With the new connection system (50) came simple way to implement different connection types.
The PR hinted a possibility of raw connections. Now raw connections have been implemented.

You can configure TSBot to use raw connections when defining `TSBot` instance:
python
bot = TSBot(
username="USERNAME",
password="PASSWORD",
address="ADDRESS",
port=10011, Important! The default port is 10022, the port for SSH.
protocol="raw"
)


Full PR 55

**Full Changelog**: https://github.com/jykob/TSBot/compare/1.3.2...1.4.0

Page 1 of 2

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.