smdb-api


Namesmdb-api JSON
Version 0.13.3 PyPI version JSON
download
home_pagehttps://github.com/NightKey/smdb-api
SummaryAPI package for Server Monitoring Discord Bot
upload_time2024-08-10 12:33:58
maintainerNone
docs_urlNone
authorJanthó Dávid
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Server monitoring Discord bot API

This API can be used to interface with the [Server Monitoring Discord Bot](https://github.com/NightKey/Server-monitoring-discord-bot) only if the API is enabled on it. For this, the bot needs to run on the same PC, or the API needs to be set up to allow outside connections.

## Usage

To create an api, import the package, and use the required arguments.

```
import smdb_api
API = smdb_api.API("Test", "80716cbfd9f90428cd308acc193b4b58519a4f10a7440b97aaffecf75e63ecec")
```

Avaleable arguments:

- name: string | Used to identify the application to the api server.
- key: string | Used to verify identity with the api server.
- ip: string (optional) | Used to set the api server's IP address.
- port: integer (optional) | Used to set the api server's listening port.
- update_function: function (optional) | Sets a callback function to call, when the api server updates.

To initiate the connection, use the validate command. The validate function can get a timeout limit, so it won't hault the program, if the api server won't ansvear within a set time.

```
API.validate()
server_status = API.get_status()
```

To add a command to the bot, use the 'create_function' command, like shown here:

```
[...]
def my_callback(message):
    #Does something

API.create_function("MyScript", "Some text to help\nUsage: &MyScript <User input>\nCategory: SERVER", my_callback)
```

To send a message to someone, use the 'send_message' command:

```
[...]
discordId="##################"
API.send_message("Test message to a channel", discordId)
print(f"I sent a message to {API.get_username(discordId)}!")
```

Closing the connection safely is easy with the 'close' command.

```
[...]
API.close("Some reason for the bot logger.")
```

## Available commands

### validate

This function connects to the API server and validates itself with it. If the validation was successful, it starts a listener thread.

### get_status

This function retrieves the bot's status and returns it in a dictionary.

### get_username

This command returns the given Discord ID's username.

### is_admin

Determines if a user is admin in the bot's database.

### send_message

This command allows you to send messages in the bot's name to selected users/channels or the default channel.

### create_function

This command creates a function in the bot that can be called by a user.

### connect_to_voice

This command connects the client to the user's voice channel

### disconnect_from_voice

This command disconnects the client from the user's voice channel

### play_file

Starts the audio file on the path provided. If the file is not supported error is returned.

### add_file

Adds the audio file to the play list on the path provided. If the file is not supported error is returned.

### pause_currently_playing

Pauses the currently playing track.

### resume_paused

Resumes playing the paused track.

### skip_currently_playing

Skips the current track if other tracks are in the play list.

### stop_currently_playing

Stops the currently playing track.

### get_queue

Lists the names of the items in the playlist, starting with the currently playing file.

### set_as_hook_for_track_finished

Sets the callback for when the current tack finished playing for possible file removal. Returns the title of the finished track in a message object.

### subscribe_to_event

Subscribes a callback to an event. Returns a string that represents the string value of the previous state, string that represents the string value of the new state, and a message object containing the dm channel for the user with the discord interface.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NightKey/smdb-api",
    "name": "smdb-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Janth\u00f3 D\u00e1vid",
    "author_email": "davidjantho@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/15/f4/a3a9a8a39e4e9ea012e977b4c85eb08761c713647265918bfd92404dad6e/smdb_api-0.13.3.tar.gz",
    "platform": null,
    "description": "# Server monitoring Discord bot API\r\n\r\nThis API can be used to interface with the [Server Monitoring Discord Bot](https://github.com/NightKey/Server-monitoring-discord-bot) only if the API is enabled on it. For this, the bot needs to run on the same PC, or the API needs to be set up to allow outside connections.\r\n\r\n## Usage\r\n\r\nTo create an api, import the package, and use the required arguments.\r\n\r\n```\r\nimport smdb_api\r\nAPI = smdb_api.API(\"Test\", \"80716cbfd9f90428cd308acc193b4b58519a4f10a7440b97aaffecf75e63ecec\")\r\n```\r\n\r\nAvaleable arguments:\r\n\r\n- name: string | Used to identify the application to the api server.\r\n- key: string | Used to verify identity with the api server.\r\n- ip: string (optional) | Used to set the api server's IP address.\r\n- port: integer (optional) | Used to set the api server's listening port.\r\n- update_function: function (optional) | Sets a callback function to call, when the api server updates.\r\n\r\nTo initiate the connection, use the validate command. The validate function can get a timeout limit, so it won't hault the program, if the api server won't ansvear within a set time.\r\n\r\n```\r\nAPI.validate()\r\nserver_status = API.get_status()\r\n```\r\n\r\nTo add a command to the bot, use the 'create_function' command, like shown here:\r\n\r\n```\r\n[...]\r\ndef my_callback(message):\r\n    #Does something\r\n\r\nAPI.create_function(\"MyScript\", \"Some text to help\\nUsage: &MyScript <User input>\\nCategory: SERVER\", my_callback)\r\n```\r\n\r\nTo send a message to someone, use the 'send_message' command:\r\n\r\n```\r\n[...]\r\ndiscordId=\"##################\"\r\nAPI.send_message(\"Test message to a channel\", discordId)\r\nprint(f\"I sent a message to {API.get_username(discordId)}!\")\r\n```\r\n\r\nClosing the connection safely is easy with the 'close' command.\r\n\r\n```\r\n[...]\r\nAPI.close(\"Some reason for the bot logger.\")\r\n```\r\n\r\n## Available commands\r\n\r\n### validate\r\n\r\nThis function connects to the API server and validates itself with it. If the validation was successful, it starts a listener thread.\r\n\r\n### get_status\r\n\r\nThis function retrieves the bot's status and returns it in a dictionary.\r\n\r\n### get_username\r\n\r\nThis command returns the given Discord ID's username.\r\n\r\n### is_admin\r\n\r\nDetermines if a user is admin in the bot's database.\r\n\r\n### send_message\r\n\r\nThis command allows you to send messages in the bot's name to selected users/channels or the default channel.\r\n\r\n### create_function\r\n\r\nThis command creates a function in the bot that can be called by a user.\r\n\r\n### connect_to_voice\r\n\r\nThis command connects the client to the user's voice channel\r\n\r\n### disconnect_from_voice\r\n\r\nThis command disconnects the client from the user's voice channel\r\n\r\n### play_file\r\n\r\nStarts the audio file on the path provided. If the file is not supported error is returned.\r\n\r\n### add_file\r\n\r\nAdds the audio file to the play list on the path provided. If the file is not supported error is returned.\r\n\r\n### pause_currently_playing\r\n\r\nPauses the currently playing track.\r\n\r\n### resume_paused\r\n\r\nResumes playing the paused track.\r\n\r\n### skip_currently_playing\r\n\r\nSkips the current track if other tracks are in the play list.\r\n\r\n### stop_currently_playing\r\n\r\nStops the currently playing track.\r\n\r\n### get_queue\r\n\r\nLists the names of the items in the playlist, starting with the currently playing file.\r\n\r\n### set_as_hook_for_track_finished\r\n\r\nSets the callback for when the current tack finished playing for possible file removal. Returns the title of the finished track in a message object.\r\n\r\n### subscribe_to_event\r\n\r\nSubscribes a callback to an event. Returns a string that represents the string value of the previous state, string that represents the string value of the new state, and a message object containing the dm channel for the user with the discord interface.\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "API package for Server Monitoring Discord Bot",
    "version": "0.13.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/NightKey/smdb-api/issues",
        "Homepage": "https://github.com/NightKey/smdb-api"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35a385e28e4a36d526d41543b9fcff797f585543829847d58e545a44b6954408",
                "md5": "48483f2aeac7ea367dbb696fb8d1ecf0",
                "sha256": "9119b38c42cca0a397b16caa0860d911cc5a78678ab8ff40b777915fd26d7810"
            },
            "downloads": -1,
            "filename": "smdb_api-0.13.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "48483f2aeac7ea367dbb696fb8d1ecf0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9783,
            "upload_time": "2024-08-10T12:33:57",
            "upload_time_iso_8601": "2024-08-10T12:33:57.012606Z",
            "url": "https://files.pythonhosted.org/packages/35/a3/85e28e4a36d526d41543b9fcff797f585543829847d58e545a44b6954408/smdb_api-0.13.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15f4a3a9a8a39e4e9ea012e977b4c85eb08761c713647265918bfd92404dad6e",
                "md5": "a94506acc64bfe7a5cf3d026055e93b1",
                "sha256": "cc5175b2ac63b384c5b207f553c7d96934b6d76054f56cf4876e5d3c36ed3f90"
            },
            "downloads": -1,
            "filename": "smdb_api-0.13.3.tar.gz",
            "has_sig": false,
            "md5_digest": "a94506acc64bfe7a5cf3d026055e93b1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 12622,
            "upload_time": "2024-08-10T12:33:58",
            "upload_time_iso_8601": "2024-08-10T12:33:58.713865Z",
            "url": "https://files.pythonhosted.org/packages/15/f4/a3a9a8a39e4e9ea012e977b4c85eb08761c713647265918bfd92404dad6e/smdb_api-0.13.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-10 12:33:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NightKey",
    "github_project": "smdb-api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "smdb-api"
}
        
Elapsed time: 0.58374s