Initial commit
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
commit
25da14d692
5 changed files with 64 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.idea/
|
||||||
|
.venv/
|
13
LICENSE
Normal file
13
LICENSE
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
Version 2, December 2004
|
||||||
|
|
||||||
|
Copyright (C) 2024 mctaylors
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim or modified
|
||||||
|
copies of this license document, and changing it is allowed as long
|
||||||
|
as the name is changed.
|
||||||
|
|
||||||
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. You just DO WHAT THE FUCK YOU WANT TO.
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# ExampleBot
|
||||||
|
|
||||||
|
An example bot written in Python and [Next.py](https://git.avanpost20.ru/next/next.py) library.
|
27
client.py
Normal file
27
client.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import next
|
||||||
|
|
||||||
|
from next.ext import commands
|
||||||
|
|
||||||
|
class Client(commands.CommandsClient):
|
||||||
|
async def get_prefix(self, message: next.Message):
|
||||||
|
return "!"
|
||||||
|
|
||||||
|
async def on_ready(self):
|
||||||
|
print(f"Authorized as {self.user.name}#{self.user.discriminator}")
|
||||||
|
try:
|
||||||
|
await self.edit_status(presence=next.PresenceType.focus,
|
||||||
|
text="Watching friend requests...")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Unable to edit status. ({e})")
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def ping(self, ctx: commands.Context):
|
||||||
|
"""Returns \"Pong.\""""
|
||||||
|
message = "Pong."
|
||||||
|
await ctx.send(message)
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def say(self, ctx: commands.Context, *args):
|
||||||
|
"""Returns user input by joining user arguments with spaces"""
|
||||||
|
message = ' '.join(args)
|
||||||
|
await ctx.send(message)
|
19
main.py
Normal file
19
main.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import aiohttp
|
||||||
|
import asyncio
|
||||||
|
import client
|
||||||
|
import os
|
||||||
|
|
||||||
|
from next.ext.commands import DefaultHelpCommand
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
token = os.getenv("BOT_TOKEN")
|
||||||
|
if token is None :
|
||||||
|
print("Environment variable BOT_TOKEN is not set. Exiting.")
|
||||||
|
exit(1)
|
||||||
|
c = client.Client(session, token)
|
||||||
|
c.help_command = DefaultHelpCommand("Available commands")
|
||||||
|
print("Starting client...")
|
||||||
|
await c.start()
|
||||||
|
|
||||||
|
asyncio.run(main())
|
Loading…
Reference in a new issue