fanbookbotapi


Namefanbookbotapi JSON
Version 1.2.5 PyPI version JSON
download
home_pagehttps://github.com/fanbook-wangdage/fanbookbotapi/
Summaryfanbook bot api
upload_time2024-09-08 15:13:55
maintainerNone
docs_urlNone
authorwangdage
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 开始使用

这里使用getme做示例

```python
import fanbookbotapi

print(fanbookbotapi.getme('123').text)
```  

**1.2.2更改:发送消息函数添加参数add_Key,为了防止不添加键盘时消息出现边框,如果你需要添加键盘,请将其设置为True,否则不用管**  

# 支持的api

## bot api

- getme(token)

```
获取bot的信息
```

- sendmessage()

```
发送消息
Args:
    token (str, optional): botToken. Defaults to ''.
    chatid (int, optional): 频道id. Defaults to 0.
    biaoti (str, optional): 卡片标题. Defaults to "标题".
    ik (list, optional): 自定义键盘. Defaults to [[{"text":"下一页","callback_data":"{\"type\":\"next\",\"index\":2,\"msg\":\"114514\"}"}]].
    text (str, optional): 正文内容,如果是card模式,换行符为  4个反斜线n. Defaults to '文本'.
    biaoticolor (str, optional): 弃用,默认即可. Defaults to 'ffe4e4'.
    type (str, optional): card(内置卡片)/fanbook(特殊消息解析模式)/text(纯文本). Defaults to "card".
    shade (list, optional): 标题背景颜色,如果配置两项就是渐变色. Defaults to ['ff764a','ffb39aff'].
    backgroundColor (str, optional): 标题文本颜色. Defaults to 'ddeeff'.
    getjson (bool, optional): 设置为True就是只返回编码完成的json,不请求. Defaults to False.
    add_Key (bool, optional): 是否添加键盘. Defaults to False.
Returns:
    requests.models.Response|str: requests请求对象|编码完成的json
    token (str): botToken
sendmessage(token='',chatid=0,biaoti="标题",ik=[[{"text":"下一页","callback_data":"{\"type\":\"next\",\"index\":2,\"msg\":\"114514\"}"}]],text='文本',biaoticolor='ffe4e4',type="card",shade=['ff764a','ffb39aff'],backgroundColor='ddeeff00',getjson=False) -> requests.models.Response|str:
```

- getPrivateChat(token,userid)  

```
创建私聊频道
Args:
    token (str): botToken
    userid (int): 用户长id
Returns:
    requests.models.Response: requests请求对象
    {"ok":true,"result":{"id":510639729457618944,"guild_id":0,"type":"private","channel_type":3}}
    返回中,id代表频道id
```

- bot_websocket()

```
fanbook bot websocket接口
Args:
    token (str): bot token
    onOpen (function): ws连接成功回调
    onMessage (function): ws收到消息回调
    onError (function): ws错误回调
    onClose (function): ws关闭回调
    log_level (str, optional): 日志等级. Defaults to "DEBUG".
```

## 用户api

> 用户api仅供学习研究使用,使用造成的后果与作者无关,严禁违法、违规使用

- send_user_message()

```
请求代码由WrunDorry提供
使用userapi发送消息

    Args:
        user_token (str, optional): 用户token和bot token二选一
        bot_token (str, optional): bot token和user token二选一
        text (str, optional): 消息体. Defaults to '{\"type\":\"text\",\"text\":\"test\",\"contentType\":0}'.
        decs (str, optional): 消息预览文本. Defaults to 'test'.
        channel_id (str, optional): 频道id. Defaults to '123456'.
        guild_id (str, optional): 服务器id. Defaults to '123456'.
        key (str, optional): api_key,默认留空. Defaults to ''.
        secret (str, optional): api_secret,默认留空. Defaults to ''.
        transaction (str, optional): 请求的唯一id,一般调试使用. Defaults to '73460be6-e295-4828-8750-01022533b9f0'.
        log_level (str, optional): 日志等级. Defaults to 'DEBUG'.

    Returns:
        requests.models.Response: 返回响应
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fanbook-wangdage/fanbookbotapi/",
    "name": "fanbookbotapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "wangdage",
    "author_email": "fanbookwdg1122@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/3a/e5/5860561e59c9a09dfdd8be907909480fc06b8ed09a59738088f059b618af/fanbookbotapi-1.2.5.tar.gz",
    "platform": null,
    "description": "# \u5f00\u59cb\u4f7f\u7528\r\n\r\n\u8fd9\u91cc\u4f7f\u7528getme\u505a\u793a\u4f8b\r\n\r\n```python\r\nimport fanbookbotapi\r\n\r\nprint(fanbookbotapi.getme('123').text)\r\n```  \r\n\r\n**1.2.2\u66f4\u6539\uff1a\u53d1\u9001\u6d88\u606f\u51fd\u6570\u6dfb\u52a0\u53c2\u6570add_Key\uff0c\u4e3a\u4e86\u9632\u6b62\u4e0d\u6dfb\u52a0\u952e\u76d8\u65f6\u6d88\u606f\u51fa\u73b0\u8fb9\u6846\uff0c\u5982\u679c\u4f60\u9700\u8981\u6dfb\u52a0\u952e\u76d8\uff0c\u8bf7\u5c06\u5176\u8bbe\u7f6e\u4e3aTrue\uff0c\u5426\u5219\u4e0d\u7528\u7ba1**  \r\n\r\n# \u652f\u6301\u7684api\r\n\r\n## bot api\r\n\r\n- getme(token)\r\n\r\n```\r\n\u83b7\u53d6bot\u7684\u4fe1\u606f\r\n```\r\n\r\n- sendmessage()\r\n\r\n```\r\n\u53d1\u9001\u6d88\u606f\r\nArgs:\r\n    token (str, optional): botToken. Defaults to ''.\r\n    chatid (int, optional): \u9891\u9053id. Defaults to 0.\r\n    biaoti (str, optional): \u5361\u7247\u6807\u9898. Defaults to \"\u6807\u9898\".\r\n    ik (list, optional): \u81ea\u5b9a\u4e49\u952e\u76d8. Defaults to [[{\"text\":\"\u4e0b\u4e00\u9875\",\"callback_data\":\"{\\\"type\\\":\\\"next\\\",\\\"index\\\":2,\\\"msg\\\":\\\"114514\\\"}\"}]].\r\n    text (str, optional): \u6b63\u6587\u5185\u5bb9\uff0c\u5982\u679c\u662fcard\u6a21\u5f0f\uff0c\u6362\u884c\u7b26\u4e3a  4\u4e2a\u53cd\u659c\u7ebfn. Defaults to '\u6587\u672c'.\r\n    biaoticolor (str, optional): \u5f03\u7528\uff0c\u9ed8\u8ba4\u5373\u53ef. Defaults to 'ffe4e4'.\r\n    type (str, optional): card(\u5185\u7f6e\u5361\u7247)/fanbook(\u7279\u6b8a\u6d88\u606f\u89e3\u6790\u6a21\u5f0f)/text(\u7eaf\u6587\u672c). Defaults to \"card\".\r\n    shade (list, optional): \u6807\u9898\u80cc\u666f\u989c\u8272\uff0c\u5982\u679c\u914d\u7f6e\u4e24\u9879\u5c31\u662f\u6e10\u53d8\u8272. Defaults to ['ff764a','ffb39aff'].\r\n    backgroundColor (str, optional): \u6807\u9898\u6587\u672c\u989c\u8272. Defaults to 'ddeeff'.\r\n    getjson (bool, optional): \u8bbe\u7f6e\u4e3aTrue\u5c31\u662f\u53ea\u8fd4\u56de\u7f16\u7801\u5b8c\u6210\u7684json\uff0c\u4e0d\u8bf7\u6c42. Defaults to False.\r\n    add_Key (bool, optional): \u662f\u5426\u6dfb\u52a0\u952e\u76d8. Defaults to False.\r\nReturns:\r\n    requests.models.Response|str: requests\u8bf7\u6c42\u5bf9\u8c61|\u7f16\u7801\u5b8c\u6210\u7684json\r\n    token (str): botToken\r\nsendmessage(token='',chatid=0,biaoti=\"\u6807\u9898\",ik=[[{\"text\":\"\u4e0b\u4e00\u9875\",\"callback_data\":\"{\\\"type\\\":\\\"next\\\",\\\"index\\\":2,\\\"msg\\\":\\\"114514\\\"}\"}]],text='\u6587\u672c',biaoticolor='ffe4e4',type=\"card\",shade=['ff764a','ffb39aff'],backgroundColor='ddeeff00',getjson=False) -> requests.models.Response|str:\r\n```\r\n\r\n- getPrivateChat(token,userid)  \r\n\r\n```\r\n\u521b\u5efa\u79c1\u804a\u9891\u9053\r\nArgs:\r\n    token (str): botToken\r\n    userid (int): \u7528\u6237\u957fid\r\nReturns:\r\n    requests.models.Response: requests\u8bf7\u6c42\u5bf9\u8c61\r\n    {\"ok\":true,\"result\":{\"id\":510639729457618944,\"guild_id\":0,\"type\":\"private\",\"channel_type\":3}}\r\n    \u8fd4\u56de\u4e2d\uff0cid\u4ee3\u8868\u9891\u9053id\r\n```\r\n\r\n- bot_websocket()\r\n\r\n```\r\nfanbook bot websocket\u63a5\u53e3\r\nArgs:\r\n    token (str): bot token\r\n    onOpen (function): ws\u8fde\u63a5\u6210\u529f\u56de\u8c03\r\n    onMessage (function): ws\u6536\u5230\u6d88\u606f\u56de\u8c03\r\n    onError (function): ws\u9519\u8bef\u56de\u8c03\r\n    onClose (function): ws\u5173\u95ed\u56de\u8c03\r\n    log_level (str, optional): \u65e5\u5fd7\u7b49\u7ea7. Defaults to \"DEBUG\".\r\n```\r\n\r\n## \u7528\u6237api\r\n\r\n> \u7528\u6237api\u4ec5\u4f9b\u5b66\u4e60\u7814\u7a76\u4f7f\u7528\uff0c\u4f7f\u7528\u9020\u6210\u7684\u540e\u679c\u4e0e\u4f5c\u8005\u65e0\u5173\uff0c\u4e25\u7981\u8fdd\u6cd5\u3001\u8fdd\u89c4\u4f7f\u7528\r\n\r\n- send_user_message()\r\n\r\n```\r\n\u8bf7\u6c42\u4ee3\u7801\u7531WrunDorry\u63d0\u4f9b\r\n\u4f7f\u7528userapi\u53d1\u9001\u6d88\u606f\r\n\r\n    Args:\r\n        user_token (str, optional): \u7528\u6237token\u548cbot token\u4e8c\u9009\u4e00\r\n        bot_token (str, optional): bot token\u548cuser token\u4e8c\u9009\u4e00\r\n        text (str, optional): \u6d88\u606f\u4f53. Defaults to '{\\\"type\\\":\\\"text\\\",\\\"text\\\":\\\"test\\\",\\\"contentType\\\":0}'.\r\n        decs (str, optional): \u6d88\u606f\u9884\u89c8\u6587\u672c. Defaults to 'test'.\r\n        channel_id (str, optional): \u9891\u9053id. Defaults to '123456'.\r\n        guild_id (str, optional): \u670d\u52a1\u5668id. Defaults to '123456'.\r\n        key (str, optional): api_key\uff0c\u9ed8\u8ba4\u7559\u7a7a. Defaults to ''.\r\n        secret (str, optional): api_secret\uff0c\u9ed8\u8ba4\u7559\u7a7a. Defaults to ''.\r\n        transaction (str, optional): \u8bf7\u6c42\u7684\u552f\u4e00id\uff0c\u4e00\u822c\u8c03\u8bd5\u4f7f\u7528. Defaults to '73460be6-e295-4828-8750-01022533b9f0'.\r\n        log_level (str, optional): \u65e5\u5fd7\u7b49\u7ea7. Defaults to 'DEBUG'.\r\n\r\n    Returns:\r\n        requests.models.Response: \u8fd4\u56de\u54cd\u5e94\r\n```\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "fanbook bot api",
    "version": "1.2.5",
    "project_urls": {
        "Homepage": "https://github.com/fanbook-wangdage/fanbookbotapi/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7653b9344ac7a9988b209b2246e0692e949d1cd3299834177d6f9dd888ab7bad",
                "md5": "d4da5554f57a614863afabc02320d932",
                "sha256": "1364bddb0ba36397183a05ce55e8d0ae27d038b44efaf889640387dc5b112ab1"
            },
            "downloads": -1,
            "filename": "fanbookbotapi-1.2.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d4da5554f57a614863afabc02320d932",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10538,
            "upload_time": "2024-09-08T15:13:54",
            "upload_time_iso_8601": "2024-09-08T15:13:54.325071Z",
            "url": "https://files.pythonhosted.org/packages/76/53/b9344ac7a9988b209b2246e0692e949d1cd3299834177d6f9dd888ab7bad/fanbookbotapi-1.2.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ae55860561e59c9a09dfdd8be907909480fc06b8ed09a59738088f059b618af",
                "md5": "e065c5f08ed36f37704add71aa90375f",
                "sha256": "3cb620a2ee2aab1a40a5ce7d5aa44bf0eec5bd1394c078e025f1c7250d6cafee"
            },
            "downloads": -1,
            "filename": "fanbookbotapi-1.2.5.tar.gz",
            "has_sig": false,
            "md5_digest": "e065c5f08ed36f37704add71aa90375f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8583,
            "upload_time": "2024-09-08T15:13:55",
            "upload_time_iso_8601": "2024-09-08T15:13:55.844341Z",
            "url": "https://files.pythonhosted.org/packages/3a/e5/5860561e59c9a09dfdd8be907909480fc06b8ed09a59738088f059b618af/fanbookbotapi-1.2.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-08 15:13:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fanbook-wangdage",
    "github_project": "fanbookbotapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fanbookbotapi"
}
        
Elapsed time: 0.36234s