commit 25da14d69289a00a17810eea0cb337483a376f04 Author: mctaylors Date: Tue Nov 5 23:16:12 2024 +0300 Initial commit Signed-off-by: mctaylors diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e8ecb4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +.venv/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..90bf388 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..36b7e88 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# ExampleBot + +An example bot written in Python and [Next.py](https://git.avanpost20.ru/next/next.py) library. \ No newline at end of file diff --git a/client.py b/client.py new file mode 100644 index 0000000..28f3ab3 --- /dev/null +++ b/client.py @@ -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) \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..63a6994 --- /dev/null +++ b/main.py @@ -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()) \ No newline at end of file