No project description provided
Project description
nerimity.py
Python API wrapper for Nerimity originating from Fiiral, maintained by Deutscher775
Nerimity Server
For questions, help or anything else feel free to join the nerimity.py Nerimity server.
Quick jumps
- Current Features
See the features that the framework currently supports. - Installation
Guide on how to install nerimity.py. - Notice: Prefix Command and Slash Commands
Description of what prefix and slash commands are and what differneces there are between them. - Example Bot
An example bot you can directly use. - Use-case-examples
Many various examples on how to use specific functions.
Current features
Command Handling:
- Define and register commands using the @client.command decorator.
- Execute commands with parameters. Register event listeners using the @client.listen decorator. Handle various events such as:
- on_ready
- on_message_create
- on_message_updated
- on_message_deleted
- on_button_clicked
- on_presence_change
- on_reaction_add
- on_member_updated
- on_role_updated
- on_role_deleted
- on_role_created
- on_channel_updated
- on_channel_deleted
- on_channel_created
- on_server_updated
- on_member_join
- on_member_left
- on_server_joined
- on_server_left
- on_friend_request_sent
- on_friend_request_pending
- on_friend_request_accepted
- on_friend_removed
- on_minute_pulse
- on_hour_pulse
Message Handling:
- Send messages to channels.
- add attachments
- add buttons with custom callback
- Edit and delete messages.
- React and unreact to messages.
Attachment Handling:
- Create and upload attachments.
- Deserialize attachments from JSON.
Channel Management:
- Update channel information.
- Send messages to channels.
- Get messages from channels.
- Purge messages from channels.
- Deserialize channels from JSON.
Context Handling:
- Send messages, remove messages, and react to messages within a command context.
Invite Management:
- Create and delete server invites.
- Deserialize invites from JSON.
Member Management:
- Follow, unfollow, add friend, remove friend, and send direct messages to members.
- Kick, ban, and unban server members.
- Deserialize members and server members from JSON.
Post Management:
- Create, delete, comment on, like, and unlike posts.
- Get comments on posts.
- Deserialize posts from JSON.
Role Management:
- Create, update, and delete roles.
- Deserialize roles from JSON.
Server Management:
- Get server details and ban list.
- Create, update, and delete channels and roles.
- Create and delete invites.
- Update server members.
- Deserialize servers from JSON.
Status Management:
- Change the presence status of the bot.
Button Interaction:
- Handle button interactions and send popups.
- Deserialize button interactions from JSON.
Permissions:
- Manage user and role permissions.
- Check for specific permissions before executing commands.
- Deserialize permissions from JSON.
Installation
Option 1: Install via PyPI (recommended)
pip install nerimity
Option 2: clone this repository
- Clone the repository
git clone https://github.com/deutscher775/nerimity.py.git
- Copy the
nerimity
folder and insert it into your workspace. It should look like this:
Done!
Notice: Prefix commands and Slash Command
A prefixed command is a command that uses the set prefix in the bot's code. Bots will not react if the message does not start with the prefix.
Slash commands are registered to Nerimity directly and can be shown by typing /
into the message bar. Registered slash commands will show up there with arguments that need to be provided, if the command needs them.
Newly registered slash commands will only show up after reloading the app
Except the above stated things there are no differences between prefix and slash command.
Example commands bot
import nerimity
client = nerimity.Client(
token="YOUR_BOT_TOKEN",
prefix='!',
)
# Prefix command -> !ping
@client.command(name="ping")
async def ping(ctx: nerimity.Context, params: str):
await ctx.send("Pong!")
# Slash command -> /test
@client.slash_command(name="test", description="A test slash command")
async def test(ctx: nerimity.Context):
await ctx.send("Test successful")
@client.listen("on_ready")
async def on_ready(params):
print(f"Logged in as {client.account.username}")
client.run()
Issues
If you encounter any issues while using the framework feel free to open an Issue.
Use case examples
Sending an attachment
@client.command(name="testattachment")
async def testattachment(ctx: nerimity.Context):
file = await nerimity.Attachment.construct("test.png").upload()
result = await ctx.send("Test", attachment=file)
Sending buttons with messages
@client.command(name="testbutton")
async def testbutton(ctx: nerimity.Context):
popup_button = nerimity.Button.construct(label="Popup!", id="popuptestbutton", alert=True)
async def popup_callback(buttoninteraction: nerimity.ButtonInteraction):
user = client.get_user(buttoninteraction.userId)
buttoninteraction.send_popup("Test", f"Hello, {user.username}!")
await popup_button.set_callback(popup_callback)
message_button = nerimity.Button.construct(label="Message!", id="messagetestbutton")
async def message_callback(buttoninteraction: nerimity.ButtonInteraction):
user = client.get_user(buttoninteraction.userId)
await ctx.send(f"Hello, {user.username}!")
await message_button.set_callback(message_callback)
await ctx.send("Test", buttons=[message_button, popup_button])
Creating a post
@client.command(name="createpost")
async def createpost(ctx: nerimity.Context, params):
content = ""
for param in params:
content += param + " "
await ctx.send("Creating post with text: " + content)
post = nerimity.Post.create_post(content)
print(post)
await ctx.send("Post created.")
Commenting on a post
@client.command(name="comment")
async def comment(ctx: nerimity.Context, params):
post_id = int(params[0])
content = ""
for param in params[1:]:
content += param + " "
post = nerimity.Post.get_post(post_id)
post.create_comment(content)
await ctx.send("Commented on post.")
Deleting a post
@client.command(name="deletepost")
async def deletepost(ctx: nerimity.Context, params):
post_id = int(params[0])
post = nerimity.Post.get_post(post_id)
post.delete_post()
await ctx.send("Deleted post.")
Creating a channel
@client.command(name="createchannel")
async def createchannel(ctx: nerimity.Context, params):
title = params[0]
permissions = nerimity.Permissions.ChannelPermissions.construct(public=True, send_messages=True, join_voice=True)
print(permissions)
everyone_role = ctx.server.get_role(ctx.server.default_role_id)
new_channel = ctx.server.create_channel(title, type=nerimity.ChannelTypes.SERVER_TEXT)
await new_channel.set_permissions(permission_integer=permissions, role=everyone_role)
await ctx.send(f"Channel '{title}' created.")
Creating a role
@client.command(name="createrole")
async def createrole(ctx: nerimity.Context, params):
name = params[0]
hide_role = bool(params[1])
role = ctx.server.create_role()
role.update_role(name=name, hide_role=hide_role)
permissions = nerimity.Permissions.RolePermissions.construct(admin=True, manage_roles=True, send_messages=True)
print(permissions)
await role.set_permissions(permissions)
await ctx.send(f"Role '{name}' created.")
Setting for a role in a channel
@client.command(name="setpermissions")
async def setpermissions(ctx: nerimity.Context, params):
channel_id = int(params[0])
role_id = int(params[1])
send_messages = bool(params[2])
join_voice = bool(params[3])
channel = ctx.server.get_channel(channel_id)
role = ctx.server.get_role(role_id)
permissions = nerimity.Permissions.ChannelPermissions.construct(send_messages=send_messages, join_voice=join_voice)
await channel.set_permissions(permission_integer=permissions, role=role)
await ctx.send(f"Permissions set for role '{role.name}' in channel '{channel.name}'.")
Issues
If you encounter any issues while using the framework feel free to open an Issue.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nerimity-1.4.1.tar.gz
.
File metadata
- Download URL: nerimity-1.4.1.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4363991fbf7507a568b0c3fb8e819b0923b02a4be70a9da167818efbcd079065
|
|
MD5 |
89f2d725abe44115e356c37d095dab29
|
|
BLAKE2b-256 |
b24a8f00f908e1f18df2e4e20c5b006fb9652a52df00067f42d37b88b7f2951c
|
Provenance
The following attestation bundles were made for nerimity-1.4.1.tar.gz
:
Publisher:
pypi-build.yaml
on Deutscher775/nerimity.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
nerimity-1.4.1.tar.gz
-
Subject digest:
4363991fbf7507a568b0c3fb8e819b0923b02a4be70a9da167818efbcd079065
- Sigstore transparency entry: 216484183
- Sigstore integration time:
-
Permalink:
Deutscher775/nerimity.py@5cfed76f179ddd9eba15385b5f28d6e87ccbea4d
-
Branch / Tag:
refs/tags/v1.4.1
- Owner: https://github.com/Deutscher775
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
pypi-build.yaml@5cfed76f179ddd9eba15385b5f28d6e87ccbea4d
-
Trigger Event:
release
-
Statement type:
File details
Details for the file nerimity-1.4.1-py3-none-any.whl
.
File metadata
- Download URL: nerimity-1.4.1-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
c70b786a5a630c9b52a7740882ee5af5fd0c205da53a30b2924f77d1ac8b8d18
|
|
MD5 |
02ec2dfe82adf728a559c08908905021
|
|
BLAKE2b-256 |
06ada5feb9e6eebfa8f6a0cd80a957956104d0ee8e1014a74d0b9d33d98d42cd
|
Provenance
The following attestation bundles were made for nerimity-1.4.1-py3-none-any.whl
:
Publisher:
pypi-build.yaml
on Deutscher775/nerimity.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
nerimity-1.4.1-py3-none-any.whl
-
Subject digest:
c70b786a5a630c9b52a7740882ee5af5fd0c205da53a30b2924f77d1ac8b8d18
- Sigstore transparency entry: 216484196
- Sigstore integration time:
-
Permalink:
Deutscher775/nerimity.py@5cfed76f179ddd9eba15385b5f28d6e87ccbea4d
-
Branch / Tag:
refs/tags/v1.4.1
- Owner: https://github.com/Deutscher775
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
pypi-build.yaml@5cfed76f179ddd9eba15385b5f28d6e87ccbea4d
-
Trigger Event:
release
-
Statement type: