Skip to main content

Python TeamSpeak bot using TSBot framework

Project description

TeamSpeak Bot

TeamSpeak server query bot. This bot is mainly an example project using the TSBot framework.

✅ Features

🔧 Admin

Collection of helpful debugging commands:

  • eval <eval str>: Evaluates given python expression.
  • exec <exec str>: Executes given python expression. Persists any side-effects.
  • quit: Closes the bot.
  • send <query>: Sends a raw query to the teamspeak server and return the response data.
  • spam <#lines> <text to be spammed> : Spams the current ctx of the message.
  • nickname <nickname>: Changes the bot nickname. If no nickname provided, defaults to the login name.

You probably don't want anyone running these commands, so they are locked behind checks. You can configure the bot to check for specific uids or server groups that have the permission to run these commands.

🚶 AFK Mover

Checks periodically for clients that haven't been active for given amount of time.
If such clients are found, move them to specified AFK channel.

If the bot doesn't find AFK channel, it will try to create one. You can white/blacklist channels where clients can be moved from. If you have Jail plugin enabled, You might want to add your jail channel to the blacklist.

📣 Announce

Announce a message to clients by poking them.
You can announce to a specific group or to all clients.

  • announce "Hello all": Pokes all clients with a message "Hello all"
  • announce "Team meeting now!" Staff: Pokes clients in "Staff" server group with "Team meeting now!"

⛔ Banned names

Kicks out any clients with configured nickname.
You can configure a list of banned nicknames or provide a function that return a boolean telling the bot if a given nickname is allowed.

By default, the bot will only kick the default TeamSpeak nickname: TeamSpeakUser

🎱 Fun

Comes with handful of fun commands:

  • coinflip: Flips a coin, responding with heads or tails.
  • roll <size=6>: Rolls a given sided die.

👋 Greeter

Greets new clients (clients with guest server group) with a configurable message.

🛂 Jail

Jails a client for a given amount of time.
Time can be provided as a number of seconds or <int>h<int>m<int>s meaning number of hours, minutes, and seconds respectively with out the <> (no need to provide all of them)

  • jail <nickname> <time>: Jail misbehaving client.
  • free <nickname>: Free jailed client. Don't use in pity.

😅 Jokes

Command to tell some good/bad jokes about programming:

  • joke Tells a programming related joke

⏰ Notify

Pokes client with a message after given amount of time.
Time parsing works the same as in jail command.

  • notify <time> <message>: Pokes you after given time with the provided message.

Requirements

  • Python 3.12

📦 Installation

You should always use virtual envs.

pip install teamspeak-bot

Configuration

The bot will look for a configuration module on startup.
You can pass a path to a config file with -c / --config command line argument.
The config module must include CONFIG variable.

Example config module:

from teamspeak_bot import BotConfig

# BotConfig is a type safe way for you to configure
# your bot instance. If you have misconfigured your bot,
# your IDE will yell at you.

CONFIG = BotConfig(
    username="USERNAME",
    password="PASSWORD",
    address="ADDRESS",
    plugins={},
    logging={}
)

Running the bot

NOTE: You will need provide configuration file.

teamspeak-bot
# -- OR --
python -m teamspeak_bot

Command line arguments

  • -c, --config: Path to a configuration file. Defaults to config.py
  • -l, --logfile: Path to a log file. Defaults to log.txt
  • -v, --verbose: Level of verbosity.
  • -h, --help: Prints out the help message.

Plugin configuration:

Admin

Plugin config key: admin

Key Type Explanation
enabled bool If the plugin is enabled
allowed_uids tuple[str, ...] UIDs allowed to run admin commands.
allowed_server_groups tuple[str, ...] Server groups allowed to run admin commands.
strict_server_group_checking bool By default if Admin in allowed_server_groups, any server group with the word Admin is allowed to run admin commands. This flag turns on strict matching.

Afk Mover

Plugin config key: afk_mover

Key Type Explanation
enabled bool If the plugin is enabled
afk_channel str Name of the AFK channel. doesn't match strictly
idle_time float AFK grace period in seconds
channel_whitelist tuple[str, ...] Channel names where clients will be moved.
channel_blacklist tuple[str, ...] Channel names where clients wont be moved.

Announce

Plugin config key: announce

Key Type Explanation
enabled bool If the plugin is enabled
allowed_uids tuple[str, ...] UIDs allowed to run announce commands.
allowed_server_groups tuple[str, ...] Server groups allowed to run announce commands.
strict_server_group_checking bool Match server groups strictly

Banned Names

Plugin config key: banned_names
banned_names and/or is_banned_name has to be defined if this plugin is enabled.

Key Type Explanation
enabled bool If the plugin is enabled
banned_names tuple[str, ...] Blacklisted names (case insensitive)
is_banned_name Callable[[str], bool] Function that determines if a name is banned
message str Kick message
check_period float How often bot checks for banned names in the client list in seconds

Error events

Plugin config key: error_events

Key Type Explanation
enabled bool If the plugin is enabled
invalid_invocation_message str Message when command is invoked wrongly
permission_error_message str Message when an invoker doesn't have proper permissions to run the command
permission_error_log_message str Message logged when an invoker doesn't have proper permissions to run the command
command_error_message str Message when a command handler encounters user error

Fun

Plugin config key: fun

Key Type Explanation
enabled bool If the plugin is enabled

Greeter

Plugin config key: greeter

Key Type Explanation
enabled bool If the plugin is enabled
message str Message to new user joining the server

Jail

Plugin config key: jail

Key Type Explanation
enabled bool If the plugin is enabled
can_jail_uids tuple[str, ...] UIDs allowed to jail clients.
can_jail_server_groups tuple[str, ...] Server groups allowed to jail clients.
strict_server_group_checking bool Match server groups strictly
jail_channel str Name of the jail channel.
inmate_server_group_name str Name of the server group given to jailed clients.

Jokes

Plugin config key: jokes

Key Type Explanation
enabled bool If the plugin is enabled

Notify

Plugin config key: notify

Key Type Explanation
enabled bool If the plugin is enabled
max_delay int The max notify time in seconds

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

teamspeak_bot-0.3.1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

teamspeak_bot-0.3.1-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file teamspeak_bot-0.3.1.tar.gz.

File metadata

  • Download URL: teamspeak_bot-0.3.1.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for teamspeak_bot-0.3.1.tar.gz
Algorithm Hash digest
SHA256 8422182f1bc636ded616280dde6948700f53832d13e1798da09043f58d6210ad
MD5 6bad2988a26a46d86b74c8909c76708e
BLAKE2b-256 0e52692515e7750e9af001e24ea240c5284efced968c7db280496c8dec06c506

See more details on using hashes here.

Provenance

The following attestation bundles were made for teamspeak_bot-0.3.1.tar.gz:

Publisher: publish.yaml on jykob/teamspeak-bot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file teamspeak_bot-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: teamspeak_bot-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for teamspeak_bot-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c789a648d13818a8a68da9b279632b50421b9bb26d84393d1cd6e5a6bbb5900
MD5 f4b53eaf47ade62e8fe4bb3d3ec06cfc
BLAKE2b-256 f1f6af82664e74f04e74ea9d3b817f82b92ebd98659ae1315b30c8e0785bf1bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for teamspeak_bot-0.3.1-py3-none-any.whl:

Publisher: publish.yaml on jykob/teamspeak-bot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page