Skip to main content

swagsocialbots

Now on PyPI: https://pypi.org/project/swagsocialbots/

Python module to make bots in swagsocial with swagsocial.py

Created by maxie!

Getting your API key

Log into your desired swagsocial account and go to Settings --> API

If you would like to grant manage post permissions, which includes making posts and replies. It also allows deleting posts and replies, so be careful!

an example

from swagsocialbots import SwagBot, Context
from swagsocialbots import tasks
from swagsocial_py import User

bot = SwagBot(prefix = "!", base_url = "https://swag.example.com")

# example command
# on swagsocial you would mention the bot
# write the command afterwards, and the arguments for it
#
# here its gonna be "@botexample !hello @user"
# will reply with "Hello User Display Example"
#
# annotating your arguments with desired class will make the
# command parser return the class instance you need such
# as in the example below
@bot.command()
async def hello(ctx: Context, user: User):
    await ctx.reply(f"Hello {user.display_name}")

@bot.event() # will reply to a post the bot is tagged on
async def on_mention(ctx: Context):
    await ctx.reply(f"Hello, {ctx.post.author.mention()}")

# will reply with an error message related to the comamnd
@bot.event()
async def on_command_error(ctx: Context, exception: Exception):
    await ctx.reply(f"something went wrong: {exception.__class__.__name__}: {exception}")

@bot.event()
async def on_error(ctx: Context, exception: Exception):
    # for now exception in this block will always be "Command not found"
    await ctx.reply(f"something went wrong: {exception.__class__.__name__}: {exception}")

# used for making a function repeat every N time, and N times (using for_times argument)
@tasks.repeat_every(hours = 1) # add for_times = <int> to repeat this function for a specific amount of times before stopping
async def post_meow():
    await bot.post("meow") # will post meow every 1 hour

@bot.event()
async def on_start():
    print("bot started")

bot.run("api key")

more in depth examples are in here

Metadata

Release files for swagsocialbots 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swagsocialbots 1.0.4
File Size Uploaded Provenance
swagsocialbots-1.0.4.tar.gz 18.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for swagsocialbots 1.0.4
File Interpreter ABI Platform
swagsocialbots-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 36.6 kB

Release files / swagsocialbots-1.0.4.tar.gz

Download URL swagsocialbots-1.0.4.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
26448f60f8323852535c65e1c92a129d8e090c92993f4e8ab05756a9326177dd
BLAKE2b-256 checksum
How to use checksums
76a29d10d29408f9e69fb5294d2ce18523db1842e858840842683fd313b99b61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / swagsocialbots-1.0.4-py3-none-any.whl

Download URL swagsocialbots-1.0.4-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f90372f9eef32de28de357cbfead2dd819037e1bf35da9b434d86e561a751d5c
BLAKE2b-256 checksum
How to use checksums
c0830d8604aeb91ee6ba0e6af416d4d02b7ea1bfd8418954297c8735d78f93a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for swagsocialbots 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page