Name | nandboxbotsapi JSON |
Version |
1.4.0
JSON |
| download |
home_page | None |
Summary | A Python library to interact with official nandbox Bot API. |
upload_time | 2024-09-26 15:47:01 |
maintainer | None |
docs_url | None |
author | Amir Salah |
requires_python | <4,>=3.9 |
license | None |
keywords |
nandbox
bot
api
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# A Python nandbox Bot API
A Python library to interact with official Nandbox Bot API. A bot token is **required** and can be obtained [this way](https://www.youtube.com/watch?v=FXb6tjOuxSc).
## Build your first bot
You can easily build your bot by following the below steps:
**1.Setup your configuration object** once you get your bot configuration data from nandbox app , copy it to a `config` object.
If you don't know how to get bot configuration data and token from nandbox
- Open your bot in nandbox app then open the top right menu and click to `Get token` .This process explained in this [video](https://www.youtube.com/watch?v=FXb6tjOuxSc&feature=youtu.be).
You will get data like this:
```
token:90091783784280234234WBBPmJAnSD5ILIkc6N6QjY3ZzeY
url:wss://<SERVER>:<PORT>/nandbox/api/
download:https://<SERVER>:<PORT>/nandbox/download/
upload:https://<SERVER>:<PORT>/nandbox/upload/
```
Add your token and the other data to `config.json` file just like below :
```json
{
"Token": "<your token>",
"URI": "wss://<SERVER>:<PORT>/nandbox/api/",
"DownloadServer": "https://<SERVER>:<PORT>/nandbox/download/",
"UploadServer": "https://<SERVER>:<PORT>/nandbox/upload/"
}
```
**2.Implement your main.py file :** To do that please follow the next instructions:
1. Make sure `config.json` file is created.
2. Implement the `CallBack.on_connect` function.
3. Implement the rest of the functions as your application requires.
```python
import json
from nandboxbots.nandbox import Nandbox
from nandboxbots.NandboxClient import NandboxClient
from nandboxbots.util.Utils import get_unique_id
CONFIG_FILE = "./config.json"
f = open(CONFIG_FILE)
config = json.load(f)
f.close()
TOKEN = config['Token']
client = NandboxClient.get(config)
nandbox = Nandbox()
napi = nandbox.Api()
class CallBack(nandbox.Callback):
def on_connect(self, api):
global napi
napi = api
print("Connected")
def on_close(self):
print("Closed")
def on_error(self):
print("Error")
def on_receive(self, incoming_msg):
print("Message Received")
if incoming_msg.is_text_msg():
chatId = incoming_msg.chat.id
text = incoming_msg.text
reference = get_unique_id()
napi.send_text(chat_id=chatId, text=text, reference=reference)
callBack = CallBack()
client.connect(config['Token'], callBack)
```
____Have a look at the [test](https://github.com/nandbox/nandboxbotsapi-py/tree/main/nandboxbots/test) folder, you might find useful examples.____
## License
MIT License
Copyright (c) 2023 nandbox
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Raw data
{
"_id": null,
"home_page": null,
"name": "nandboxbotsapi",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.9",
"maintainer_email": null,
"keywords": "nandbox, bot, api",
"author": "Amir Salah",
"author_email": "ameer.alahmedy@nandbox.com",
"download_url": "https://files.pythonhosted.org/packages/3f/74/964b6948e1c1083bca981fd78f302dd8d33f6576123ac8613a52fec70a45/nandboxbotsapi-1.4.0.tar.gz",
"platform": null,
"description": "# A Python nandbox Bot API\r\n\r\n\r\nA Python library to interact with official Nandbox Bot API. A bot token is **required** and can be obtained [this way](https://www.youtube.com/watch?v=FXb6tjOuxSc).\r\n\r\n## Build your first bot\r\nYou can easily build your bot by following the below steps:\r\n\r\n**1.Setup your configuration object** once you get your bot configuration data from nandbox app , copy it to a `config` object.\r\n\r\nIf you don't know how to get bot configuration data and token from nandbox \r\n\r\n- Open your bot in nandbox app then open the top right menu and click to `Get token` .This process explained in this [video](https://www.youtube.com/watch?v=FXb6tjOuxSc&feature=youtu.be).\r\n\r\n\r\nYou will get data like this:\r\n``` \r\ntoken:90091783784280234234WBBPmJAnSD5ILIkc6N6QjY3ZzeY\r\nurl:wss://<SERVER>:<PORT>/nandbox/api/ \r\ndownload:https://<SERVER>:<PORT>/nandbox/download/ \r\nupload:https://<SERVER>:<PORT>/nandbox/upload/\r\n```\r\nAdd your token and the other data to `config.json` file just like below :\r\n```json\r\n{\r\n \"Token\": \"<your token>\",\r\n \"URI\": \"wss://<SERVER>:<PORT>/nandbox/api/\",\r\n \"DownloadServer\": \"https://<SERVER>:<PORT>/nandbox/download/\", \r\n \"UploadServer\": \"https://<SERVER>:<PORT>/nandbox/upload/\"\r\n}\r\n```\r\n\r\n**2.Implement your main.py file :** To do that please follow the next instructions:\r\n1. Make sure `config.json` file is created.\r\n2. Implement the `CallBack.on_connect` function.\r\n3. Implement the rest of the functions as your application requires.\r\n\r\n```python\r\nimport json\r\n\r\nfrom nandboxbots.nandbox import Nandbox\r\nfrom nandboxbots.NandboxClient import NandboxClient\r\nfrom nandboxbots.util.Utils import get_unique_id\r\n\r\nCONFIG_FILE = \"./config.json\"\r\n\r\nf = open(CONFIG_FILE)\r\nconfig = json.load(f)\r\nf.close()\r\n\r\nTOKEN = config['Token']\r\n\r\nclient = NandboxClient.get(config)\r\n\r\nnandbox = Nandbox()\r\n\r\nnapi = nandbox.Api()\r\n\r\n\r\nclass CallBack(nandbox.Callback):\r\n def on_connect(self, api):\r\n global napi\r\n napi = api\r\n print(\"Connected\")\r\n\r\n def on_close(self):\r\n print(\"Closed\")\r\n\r\n def on_error(self):\r\n print(\"Error\")\r\n\r\n def on_receive(self, incoming_msg):\r\n print(\"Message Received\")\r\n\r\n if incoming_msg.is_text_msg():\r\n chatId = incoming_msg.chat.id\r\n text = incoming_msg.text\r\n reference = get_unique_id()\r\n napi.send_text(chat_id=chatId, text=text, reference=reference)\r\n\r\n\r\ncallBack = CallBack()\r\nclient.connect(config['Token'], callBack)\r\n```\r\n\r\n____Have a look at the [test](https://github.com/nandbox/nandboxbotsapi-py/tree/main/nandboxbots/test) folder, you might find useful examples.____\r\n\r\n## License \r\nMIT License\r\n\r\nCopyright (c) 2023 nandbox\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library to interact with official nandbox Bot API.",
"version": "1.4.0",
"project_urls": {
"Bug Reports": "https://github.com/nandbox/nandboxbotsapi-py/issues",
"Source": "https://github.com/nandbox/nandboxbotsapi-py"
},
"split_keywords": [
"nandbox",
" bot",
" api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2076c1d7d7d97d623750d27692b7206b9ba952f2cc4fb0952e764910fc961497",
"md5": "c60a844945553c30a7c30ec91917ee13",
"sha256": "5e33252724e5ad519aea47a4688852dbd4ca36fbea883ca6664582046e92c5fb"
},
"downloads": -1,
"filename": "nandboxbotsapi-1.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c60a844945553c30a7c30ec91917ee13",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 65438,
"upload_time": "2024-09-26T15:46:59",
"upload_time_iso_8601": "2024-09-26T15:46:59.443083Z",
"url": "https://files.pythonhosted.org/packages/20/76/c1d7d7d97d623750d27692b7206b9ba952f2cc4fb0952e764910fc961497/nandboxbotsapi-1.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3f74964b6948e1c1083bca981fd78f302dd8d33f6576123ac8613a52fec70a45",
"md5": "6efeb0acd8c1a533d5537e6eeac3058f",
"sha256": "e41c41ebc70e1747900ffd210bbd49a90584332af836573f0ba76328142171fa"
},
"downloads": -1,
"filename": "nandboxbotsapi-1.4.0.tar.gz",
"has_sig": false,
"md5_digest": "6efeb0acd8c1a533d5537e6eeac3058f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 35403,
"upload_time": "2024-09-26T15:47:01",
"upload_time_iso_8601": "2024-09-26T15:47:01.024052Z",
"url": "https://files.pythonhosted.org/packages/3f/74/964b6948e1c1083bca981fd78f302dd8d33f6576123ac8613a52fec70a45/nandboxbotsapi-1.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-26 15:47:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nandbox",
"github_project": "nandboxbotsapi-py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "nandboxbotsapi"
}