Skip to main content

a Python library for automating activities on mafiascum.net

Project description

Donbot: Automate Activities on Mafiascum.net 🤖🤵

Donbot is a Python library for automating activities on mafiascum.net.

Forum-based mafia games are a popular form of social deduction game. Mafiascum.net is a popular forum for playing these games. Donbot is designed to make it easier to interact with the site programmatically. By having a pre-existing implementation of all the main ways to interact with the site, it should be easier for bot developers to focus on the logic of what they want done, rather than the minutiae of constructing valid requests and parsing the site's html.

For game moderators, the library can be used to automate the process of updating the game thread with votecounts, player lists, and other information. For players and researchers, the library can be used to automate the process of collecting and analyzing data from the site. Even outside of games, the tools can help manage complex threads or send mass PMs customized to each recipient.

Please don't use these functions haphazardly, especially those that make posts or send PMs, as misuse thereof can be against Site Rules, get you banned, and most importantly cause trouble for a lot of decent people.

Implemented Utilities 📋

Using donbot, we've already automated a number of common workflows on mafiascum.net and host them in Google Colaboratory notebooks. These can be executed in the cloud without any setup, making them accessible even to people who don't write code. Just click the "Open in Colab" button next to a utility to get srated. Here's a table of what we have so far:

Utility Description Open in Colab Notes
Youtube Playlist Extractor Extracts YouTube video links from a thread and compiles them into a playlist Open In Colab Tested for threads with ~50 videos
Thread Scraping Uses scrapy to download a thread's posts into a structured JSONL file See full example for multi-thread scraping!

Using the Library 🍲

Donbot is available on PyPI, so you can install it with pip:

pip install donbot-python

For most developers, it's most easy to get started by importing the Donbot class and initializing it with your account credentials -- ideally in a more secure way than hardcoding them into your script. You can either specify the thread you want to interact with when you initialize the bot (ideal when it's just that one thread), or specify it later when you call a function that requires it.

Check out donbot/donbot.py for a full list of available functions and their docstrings. Here's a basic demo of some of the things you can do with the library:

from donbot import Donbot

# instantiating the bot
bot = Donbot(
    username='myusername', 
    password='mypassword', 
    thread='https://forum.mafiascum.net/viewtopic.php?f=5&t=76109'
)

# collect and print basic information about a thread
post_count = bot.count_posts() # e.g., 24
activity_overview = bot.get_activity_overview()
print(post_count)
print(activity_overview)

# collect the first 5 posts in a thread
posts = bot.get_posts(0, 5)
for post in posts:
    print(post)

# make a post in the thread that replies to the first post 
post_content = f"[quote]{posts[0]['content']}[/quote] wow very interesting"
bot.make_post(post_content)

# then edit the post
new_content = f"{post_content} and also very cool"
bot.edit_post(post_count+1, new_content)

Advanced Usage 🛠️

The donbot library is divided into two main parts: the Donbot class and the operations submodule. The Donbot class uses the requests library to make HTTP requests to the site and calls functions from the donbot.operations submodule to extract data and prepare actions on the site.

Power users comfortable with other libraries for making HTTP requests such as scrapy or beautifulsoup can sidestep the Donbot class and use functions in the operations submodule directly to streamline interactions with the site. This can be useful for tasks such as large-scale data collection or analysis, where the requests library may not be the best tool for the job.

Check out our examples directory for scripts that demonstrate the library's interopability with other libraries and its use in more complex workflows.

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

donbot-python-0.2.0.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

donbot_python-0.2.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file donbot-python-0.2.0.tar.gz.

File metadata

  • Download URL: donbot-python-0.2.0.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for donbot-python-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ec9091ac0c3766e12d59d8cc53da6648a7752b7038a2eec6eb7294f66625d895
MD5 dfb3cd530c34fe39469100294d525773
BLAKE2b-256 6ef8ce5a586b7a2af15308b2f26d1c5e3100b9dbc308bce5fe4fee0a8866346a

See more details on using hashes here.

File details

Details for the file donbot_python-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: donbot_python-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for donbot_python-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d7fac3c9715db09fe35cb328ea6db7704e8de4866cf953d0ac1b105c644a4a0
MD5 f58b69f6226a6b84daea59ead2070d7f
BLAKE2b-256 8913eaac779832a966ccd86d70ddf2e2d8a52ed838538bd31a0df51ac471e1f7

See more details on using hashes here.

Supported by

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