Skip to main content

A meower bot lib for py

Project description

A Python Bot library with an API like nextcord or discord.py, but instead of discord, it is made for the FOSS Social media Meower

Installing

pip install MeowerBot

Examples

from MeowerBot import Bot, CallBackIds
from MeowerBot.context import Context, Post
from MeowerBot.cog import Cog
from MeowerBot.command import command

import logging

from dotenv import load_dotenv # type: ignore

load_dotenv() # type: ignore

from os import environ as env
from MeowerBot.ext.help import Help as HelpExt

logging.basicConfig(
	level=logging.DEBUG,
	handlers=[
		logging.FileHandler("debug.log", encoding='utf8'),
		logging.StreamHandler()
	]
)

logging.getLogger("websockets.client").setLevel(logging.INFO)
bot = Bot()


@bot.event
async def login(_token):
	print("Logged in!")


@bot.command(name="ping")
async def ping(ctx: Context):
	await ctx.send_msg("Pong!\n My latency is: " + str(bot.latency))


# noinspection PyIncorrectDocstring
@bot.command(name="logs")
async def get_logs(ctx: Context, *args):
	"""
	Arguments:
		start: Optional[int]
		end: Optional[int]

	Formated like this:
		start=...

	@prefix get_logs start=-200 end=-1
	"""
	# start=...
	# end=...
	start = -10
	end = -1
	arg: str
	for arg in args:
		if arg.startswith("start"):
			start = int(arg.split("=")[1])
		elif arg.startswith("end"):
			end = int(arg.split("=")[1])

	with open("debug.log") as logfile:
		logs = logfile.readlines()

	message = await ctx.send_msg("".join(logs[start: end]))
	if not message:
		await ctx.reply("Error: Logs to big for current env")


@bot.command(name="bots")
async def get_bots(ctx: Context):
	await ctx.reply(f"\n {" ".join(list(bot.cache.bots.keys()))}")


@ping.subcommand(name="pong")
async def pong(ctx: Context, *message: str):
	await ctx.send_msg(f"Pong!{" ".join(message)}")


class Ping(Cog):
	def __init__(self, bot: Bot):
		super().__init__()
		self.bot = bot

	@command()
	async def cog_ping(self, ctx: Context):
		await ctx.send_msg("Pong!\n My latency is: " + str(self.bot.latency))
		print(bot.api.headers.get("token"))
	@cog_ping.subcommand()
	async def ping(self, ctx: Context):
		await ctx.send_msg("Pong!\n My latency is: " + str(self.bot.latency))





bot.register_cog(Ping(bot))
bot.register_cog(HelpExt(bot, disable_command_newlines=True))
bot.run(env["uname"], env["pswd"])

That example may be outdated.
(Updated as of 1/8/2024 CT) If it is outdated, the place where it is taken from is the login test

Extra links

There are extra examples in the intergration tests The docs are located on my domain made with sphinx. They are located here MeowerBot.py's MIT LICENSE

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

meowerbot-3.3.2.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

meowerbot-3.3.2-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file meowerbot-3.3.2.tar.gz.

File metadata

  • Download URL: meowerbot-3.3.2.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.12.0 Windows/10

File hashes

Hashes for meowerbot-3.3.2.tar.gz
Algorithm Hash digest
SHA256 e9fa4f0a6f17365a09219b1be5dce8af412de4003fd1d0ef1c76eca56171c401
MD5 d7d9c5435e2c05c5f6190925037fc64c
BLAKE2b-256 b54720385d0a4a82d497a7177f7fd8d7d115b29cb1fa3818edccd49cd15c6c8d

See more details on using hashes here.

File details

Details for the file meowerbot-3.3.2-py3-none-any.whl.

File metadata

  • Download URL: meowerbot-3.3.2-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.12.0 Windows/10

File hashes

Hashes for meowerbot-3.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 75c1c9d57e4ecf416e0687822d03fe05213fdb14244893d48f8e6d6501035944
MD5 390b937ea17b9719f9b9a650dab5e372
BLAKE2b-256 e3e782828a33c3b4d9f74d1d4c17d1efdd6a7a489cbabdc0300f0d2e3ae0015c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page