Skip to main content

Revolt 的简单 Pythonic 异步 API 包装器。

项目描述

起义支持服务器 皮皮页面。 文档状态 GitHub 工作流状态

一个简单的 Python 异步 API 包装器,用于Revolt。

启动机器人的屏幕截图。

用法

import voltage  # Import voltage.

client = voltage.Client()  # Initialize the client.


@client.listen("ready")  # Listen to an event.
async def on_ready():
    print(f"Logged in as {client.user}")


@client.listen("message")
async def on_message(message):  # Doesn't matter what you call the function.
    if message.content == "-ping":
        await message.channel.send("pong!")  # Send a message.
    elif message.content == "-embed":
        embed = voltage.SendableEmbed(title="Hello World", description="This is an embed")  # Create an embed.
        # Reply to a message.
        await message.reply(content="embed", embed=embed)  # Obligatory message content.

# Run the client which is an abstraction of calling the start coroutine.
client.run("TOKEN")  # Replace with your token.

命令框架示例:

import voltage
from voltage.ext import commands # Import the commands module from ``voltage.ext``

client = commands.CommandsClient("-") # Create a CommandsClient (client that has commands (original ik)) with the prefix set to "-".

@client.listen("ready") # You can still listen to events.
async def ready():
    print("Gaaah, It's rewind time.")

@client.command() # Register a command using the ``command`` decorator.
async def ping(ctx):
    """Sends Pong!""" # Name and description can be passed in the decorator or automatically inferred.
    await ctx.reply("Pong") # Reply to the context's message.

client.run("TOKEN") # Again, replace with your bot token.

有关更多示例,请查看示例文件夹,其中包含许多有用的、准备好的和解释的示例。

安装

PyPI上提供电压!

要安装电压,只需运行:

$ pip install voltage

如果要安装可能具有更多功能但更不稳定的主分支,请运行:

$ pip install git+https://github.com/EnokiUN/voltage

学分

  • 贡献者,谢谢你:)

  • Revolt.py,当狗屎坏了,这就是我去的地方。

  • Revolt.js,当文档失败时。

  • Discord.py,在制作这个时也有很大的帮助。

  • 反抗开发团队,绝对的乍得。

  • FatalErrorCoded,Vortex 的家伙,带着语音实现,吃掉了 chadness。

  • RGBCube,想出了一个了不起的名字“Voltage”。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

电压-0.1.5a8.tar.gz (50.9 kB 查看哈希

已上传 source

内置分布

voltage-0.1.5a8-py3-none-any.whl (64.1 kB 查看哈希

已上传 py3