Skip to content

Commit

Permalink
Fixed some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Mydayyy committed Sep 24, 2017
1 parent 255c775 commit 6bbe722
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 28 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# TeamspeakBot ( WIP )

This is a teamspeak bot which provides all needed functionality to plugins and can be extended endlessly by those. A MySQL server is currently required to run this bot, as it stores its data there.
This is a teamspeak bot which provides all needed functionality to plugins
and can be extended endlessly by those. A MySQL server is currently required
to run this bot, as it stores its data there.

## TODO
- Add SQLite as an alternative to MySQL
Expand All @@ -9,18 +11,22 @@ This is a teamspeak bot which provides all needed functionality to plugins and c

## Bot Requirements
To use this Bot you must meet the following criteria:
- You are running python 3.(TBD)
- You are running python 3.4
- You are able to provide a MySQL Database for the Bot
- You have the package pymysql installed, as the Bot uses this MySQL driver

## Bot Setup
- Clone or download this repository
- Duplicate config.json.sample and name it config.json
- Fill in your values. You can find a complete explanation about the config [here](#)
- Import the sql dump into your database
- Run Main.py in the root directory

## How to develop plugins
Take a look at Bot/Plugins/Example.py which is a plugin implementing every possible callback and event provided by the bot. Otherwise head to the [develop documentation](doc/develop.md) for more information about the event structure as well as possible caveats.
Take a look at Bot/Plugins/Example.py which is a plugin implementing
every possible callback and event provided by the bot.
Otherwise head to the [develop documentation](doc/develop.md) for more
information about the event structure as well as possible caveats.

## Core contribution
To be written
20 changes: 12 additions & 8 deletions doc/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ multiple configs in one file and easily swap them out. Inside your namespace you


- bot_name: Sets the name of the main bot. The bot will try to set his name as soon as he connect.
in the future there will also be the possibility to handle an situation, where the botname is already taken
In the future there will also be the possibility to handle the situation when the botname is already taken

- command_prefix: Every command needs to be prefix with the given string here. E.g if the command is
- command_prefix: Every command needs to be prefixed with the given string here. E.g if the command is
subscribe and the command_prefix is a dot, the command needs to be .subscribe

- channel_text: Enables the possibility to track chat messages in every channel. This comes with a caveat
- channel_text: Enables the possibility to track text messages in every channel. This comes with a caveat
due to teamspeak limitations: Every channel with one or more clients needs to have a serverquery client in it,
thus occupying many slots.

- load_all_plugins: When this is true, the bot will load all plugins which are in Bot/Plugins.
- load_all_plugins: When this is set to true, the bot will load all plugins which are in Bot/Plugins.
Otherwise only plugins specified in plugin_list will be loaded.

- plugin_list: A list of strings with plugin names to load. Only needed when `load_all_plugins` is false.
Expand All @@ -28,15 +29,18 @@ E.g `["AFKSwitcher", "YoutubePlugin"]`. You need to input the actual file names
- user: mysql user
- password: mysql password
- db: db to use, you need to have imported the sql dump there

- serverquery
- host: domain or IP to connect to
- port: port ( when in doubt, set it to 10011 as its the default port)
- user: serverquery user
- password: serverquery password
- virtualserverid: virtual ID of that server. Usually 1 if you only have one virtual server running
- accesslevel: Configure accesslevel for you servergroups here
- default: The default accesslevel. When in doubt set to 0
- groups: You can add servergroups and their accesslevel here
- virtualserverid: virtual ID of that server. Usually 1 if you only have one virtual server running.

- accesslevel: Configure accesslevel for your servergroups here
- default: The default accesslevel. When in doubt set to 0.
- groups: You can add servergroups and their accesslevel here.

- plugins: Move plugin specific configuration here. Every plugin is encouraged
to make them as configurable as possible. Plugins are supposed to have atleast
a class docstring explaining possible commands and config values as well as
Expand Down
143 changes: 126 additions & 17 deletions doc/data-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,153 @@ teamspeak server. The event object has three members:
- data: holds user defined data which was given in the send_command call
- bot: holds the bot instance

`args` is guaranted to be an array. Every item in that array is a dictionary, where the key corresponds to a field in the received query answer. For most teamspeak query answers, this array will only be one item long ( e.g on_client_joined, on_client_left ). An example for an array with multiple items would be `clientlist`.
`args` is guaranteed to be an array. Every item in that array is a dictionary,
where the key corresponds to a field in the received query answer.
For most teamspeak query answers, this array will only be one item long ( e.g on_client_joined, on_client_left ).
An example for an array with multiple items would be `clientlist`.

### Example:

Teamspeak returns an array of clients for the command `clientlist`. When you send the command `clientlist` via `send_command("clientlist", callback=lambda e: print(e.args))` teamspeak will answer with a list of all clients, looking like this:

```clid=1 cid=1 client_database_id=2 client_nickname=Client2 client_type=0|clid=3 cid=1 client_database_id=2 client_nickname=Client1 client_type=0|clid=5 cid=1 client_database_id=1 client_nickname=serveradmin\sfrom\s127.0.0.1:37322 client_type=1```

The bot will normalize this to the following array of dictionaries:

```[{'clid': '1', 'cid': '1', 'client_database_id': '2', 'client_nickname': 'Client2', 'client_type': '0'}, {'clid': '3', 'cid': '1', 'client_database_id': '2', 'client_nickname': 'Client1', 'client_type': '0'}, {'clid': '5', 'cid': '1', 'client_database_id': '1', 'client_nickname': 'serveradmin from 127.0.0.1:37322', 'client_type': '1'}]```
Teamspeak returns an array of clients for the command `clientlist`.
When you send the command `clientlist` via
`send_command("clientlist", callback=lambda e: print(e.args))` teamspeak
will answer with a list of all clients, looking like this:

```
clid=1 cid=1 client_database_id=2 client_nickname=Client2 client_type=0|
clid=3 cid=1 client_database_id=2 client_nickname=Client1 client_type=0
```

The bot will normalize this to the following array of dictionaries,
that is also what you find in event.args:

```
[
{
'clid': '1',
'cid': '1',
'client_database_id': '2',
'client_nickname': 'Client2',
'client_type': '0'
},
{
'clid': '3',
'cid': '1',
'client_database_id': '2',
'client_nickname': 'Client1',
'client_type': '0'
}
]
```

<br>
<br>

## on_client_joined event args

```[{'notifycliententerview': '', 'cfid': '0', 'ctid': '1', 'reasonid': '0', 'clid': '11', 'client_unique_identifier': 'CRhMp/NFyvdP1D8DDooQIr8gAWI=', 'client_nickname': 'ClientName', 'client_input_muted': '0', 'client_output_muted': '1', 'client_outputonly_muted': '0', 'client_input_hardware': '1', 'client_output_hardware': '1', 'client_meta_data': '', 'client_is_recording': '0', 'client_database_id': '2', 'client_channel_group_id': '8', 'client_servergroups': '6,7', 'client_away': '0', 'client_away_message': '', 'client_type': '0', 'client_flag_avatar': '', 'client_talk_power': '75', 'client_talk_request': '0', 'client_talk_request_msg': '', 'client_description': '', 'client_is_talker': '0', 'client_is_priority_speaker': '0', 'client_unread_messages': '0', 'client_nickname_phonetic': '', 'client_needed_serverquery_view_power': '75', 'client_icon_id': '0', 'client_is_channel_commander': '0', 'client_country': '', 'client_channel_group_inherited_channel_id': '1', 'client_badges': '', 'cid': '1'}]```
```
[
{
'notifycliententerview': '',
'cfid': '0',
'ctid': '1',
'reasonid': '0',
'clid': '11',
'client_unique_identifier': 'CRhMp/NFyvdP1D8DDooQIr8gAWI=',
'client_nickname': 'ClientName',
'client_input_muted': '0',
'client_output_muted': '1',
'client_outputonly_muted': '0',
'client_input_hardware': '1',
'client_output_hardware': '1',
'client_meta_data': '',
'client_is_recording': '0',
'client_database_id': '2',
'client_channel_group_id': '8',
'client_servergroups': '6,7',
'client_away': '0',
'client_away_message': '',
'client_type': '0',
'client_flag_avatar': '',
'client_talk_power': '75',
'client_talk_request': '0',
'client_talk_request_msg': '',
'client_description': '',
'client_is_talker': '0',
'client_is_priority_speaker': '0',
'client_unread_messages': '0',
'client_nickname_phonetic': '',
'client_needed_serverquery_view_power': '75',
'client_icon_id': '0',
'client_is_channel_commander': '0',
'client_country': '',
'client_channel_group_inherited_channel_id': '1',
'client_badges': '',
'cid': '1'
}
]
```

<br>

## on_client_left event args

```[{'notifyclientleftview': '', 'cfid': '1', 'ctid': '0', 'reasonid': '8', 'reasonmsg': 'leaving', 'clid': '11'}]```
```
[
{
'notifyclientleftview': '',
'cfid': '1',
'ctid': '0',
'reasonid': '8',
'reasonmsg': 'leaving',
'clid': '11'
}
]
```

<br>

## on_client_moved event args

```[{'notifyclientmoved': '', 'ctid': '3', 'reasonid': '0', 'clid': '12', 'cid': '2'}]```
```
[
{
'notifyclientmoved': '',
'ctid': '3',
'reasonid': '0',
'clid': '12',
'cid': '2'
}
]
```

<br>

## on_private_text event args

```[{'notifytextmessage': '', 'targetmode': '1', 'msg': 'Message Body', 'target': '14', 'invokerid': '1', 'invokername': 'Client2', 'invokeruid': 'CRhMp/NFyvdP1D8DDooQIr8gAWI='}]```
```
[
{
'notifytextmessage': '',
'targetmode': '1',
'msg': 'Message Body',
'target': '14',
'invokerid': '1',
'invokername': 'Client2',
'invokeruid': 'CRhMp/NFyvdP1D8DDooQIr8gAWI='
}
]
```

<br>

## on_channel_text
```[{'notifytextmessage': '', 'targetmode': '2', 'msg': 'Hello', 'invokerid': '1', 'invokername': 'ClientName', 'invokeruid': 'CRhMp/NFyvdP1D8DDooQIr8gAWI=', 'cid': 2}]```
```
[
{
'notifytextmessage': '',
'targetmode': '2',
'msg': 'Hello',
'invokerid': '1',
'invokername': 'ClientName',
'invokeruid': 'CRhMp/NFyvdP1D8DDooQIr8gAWI=',
'cid': 2
}
]
```

0 comments on commit 6bbe722

Please sign in to comment.