Skip to content

Plugin Usage

runoneall edited this page Dec 11, 2024 · 14 revisions
简体中文 | English
Language translations may not be 100% accurate

Import Plugin

from RyhBotPythonSDK.Plugin import Plugin

Plugin Manager

This manager is a python file. Run python3 plugin-tool.py with python to get usage instructions.

Install Plugin From Url

python3 plugin-tool.py install <url>
  • <url>: Resource address, a compressed package ending in .zip format

Install Plugin From Local File

python3 plugin-tool.py loadfile <file path>
  • <file path>: File address. When you cannot download the plug-in through the Internet, use this command to install it from a local file. It is a compressed package ending in .zip format.

Show A Plugin Info

python3 plugin-tool.py info <plugin name>
  • <plugin name>: Plugin name, use this command to get detailed information about a plugin

List Installed Plugins

python3 plugin-tool.py list

List all installed plugins

Remove Plugin

python3 plugin-tool.py remove <plugin name>
  • <plugin name>: Plugin name, use this command to remove a plugin

plugin_Html

A built-in plugin. Provides Html message support for RyhBotPythonSDK

Import Module

HtmlPlugin = Plugin.Html

Set Token

HtmlPlugin.SendHtml.Token="Your message token can be found in the Yunhu backend"

Sending Html messages

HtmlPlugin.SendHtml.Send(
    recvId = "Target ID",
    recvType = "Target Type",
    html = 'HTML text'
)

plugin_Sqlite

A built-in plugin. Easier and more intuitive use of Sqlite database

Import Module

SqlitePlugin = Plugin.Sqlite

Connect Database

database, cursor = SqlitePlugin.db.connect('Path to your sqlite file')
SqlitePlugin.Execute.database = database

Create Table

SqlitePlugin.Execute.create_table(
    cursor, 
    table_info = {
        'name': 'Table Name',
        'item': [
            {'id': 'INTEGER PRIMARY KEY AUTOINCREMENT'}, # Key
            {'text': 'TEXT'}, # Item
            ... # Items
        ]
    }
)

Insert

SqlitePlugin.Execute.insert(
    cursor, 
    insert_info = {
        'name': 'Table Name',
        'item': [
            {'text': '"aaa"'}, # Item
            ... # Items
        ]
    }
)

Drop Table

SqlitePlugin.Execute.drop_table(
    cursor, 
    table_name = 'Table Name'
)

Run Command

result = SqlitePlugin.Execute.run_command(
    cursor, 
    "Sql Command"
)
print(result)

Delete

SqlitePlugin.Execute.delete(
    cursor,
    table_name = 'Table Name',
    condition = 'id=1' # Filter conditions, optional
)

Update

SqlitePlugin.Execute.update(
    cursor,
    update_info = {
        'name': 'Table Name',
        'item': [
            {'text': '"update test"'}, # Item
            ... # Items
        ]
    },
    condition = 'id=1' # Filter conditions, optional
)

Select

result = SqlitePlugin.Execute.select(
    cursor,
    table_name = 'Table Name',
    condition = 'id=1' # Filter conditions, optional
)
print(result)

Disconnect Database

SqlitePlugin.db.disconnect(cursor, database)

plugin_MySql

A built-in plugin. Easier and more intuitive use of MySql database

Import Module

MysqlPlugin = Plugin.MySql

Connect to database

database, cursor = MysqlPlugin.db.connect(
    host="Mysql Host Address",
    port=Mysql Port,
    user="Mysql User Name",
    password="Mysql Password",
    database="Target Database Name"
)
MysqlPlugin.Execute.database = database

Create Table

MysqlPlugin.Execute.create_table(
    cursor,
    table_info = {
        'name': 'Table Name',
        'item': [
            {'id': 'INT PRIMARY KEY AUTO_INCREMENT'}, # Key
            {'text': 'TEXT'}, # Item
            ... # Items
        ]
    }
)

Insert

MysqlPlugin.Execute.insert(
    cursor, 
    insert_info = {
        'name': 'Table Name',
        'item': [
            {'text': "'aaa'"}, # Item
            ... # Items
        ]
    }
)

Drop Table

MysqlPlugin.Execute.drop_table(
    cursor,
    table_name = 'Table Name'
)

Run Command

result = MysqlPlugin.Execute.run_command(
    cursor,
    "Sql Command"
)
print(result)

Delete

MysqlPlugin.Execute.delete(
    cursor,
    table_name = 'Table Name',
    condition = 'id=1' # Filter conditions, optional
)

Update

MysqlPlugin.Execute.update(
    cursor,
    update_info = {
        'name': 'Table Name',
        'item': [
            {'text': "'bbb'"}, # Item
            ... # Items
        ]
    },
    condition = 'id=1' # Filter conditions, optional
)

Select

result = MysqlPlugin.Execute.select(
    cursor,
    table_name = 'Table Name',
    condition = 'id=1' # Filter conditions, optional
)
print(result)

Disconnect Database

MysqlPlugin.db.disconnect(database, cursor)

This document is written by English and 简体中文.

English


本文档由English和简体中文编写。

简体中文

Clone this wiki locally