pravda

Crates.iopravda
lib.rspravda
version0.1.3
sourcesrc
created_at2023-10-17 23:29:32.067968
updated_at2023-10-31 13:00:28.930593
descriptionA bot to connect to a fediverse instance using the mastodon API and host social games.
homepagehttps://modulus.isonomia.net/pravda.cgi/wiki/home
repositoryhttps://modulus.isonomia.net/pravda.cgi
max_upload_size
id1006191
size82,082
David (bingen13)

documentation

README

Pravda: social games for a social network.

This crate is a functional bot that you can use to connect to a mastodon server (or one providing a similar API) in order to run social games. For now it can be used to play Rock, Paper, Scissors, or roll dice. The code is written modularly so that it is relatively easy to add new games.

The Game trait defines the behaviour for a game, involving an associated method new for setup, and a method next which receives user toots and is responsible to advance the state of the game. Every game receives every message and must be able to discard anything that is irrelevant to it.

There are some constants to shut down the bot remotely with a toot. ADMIN contains the administrative account, QUIT contains the quit message which must be sent as a mention to the bot, and INSTANCE contains the URL of the instance to connect to. At the moment, it uses my own fedi account by default, and the message !QUIT! but you should customise this if you deploy. The default instance is botsin.space, an appropriate instance for bots, but you should change this if you want to run it somewhere else.

Bear in mind you must have a valid account on the instance before you attempt to authorise the bot.

First run.

Decide where you want to execute the game, and make sure you have write permissions. The game will connect to an instance and attempt to establish an OAuth flow, asking you to visit a link and authorise the application with your mastodon/fedi account.

Once this is done, the information is written into a toml file, which should remain private, as it contains a token that allows for almost full control of the account it's authorised under.

On subsequent runs, if this file is encountered, the information will be read from it and the connection will be realised without human intervention.

Limitations.

It is not possible to connect this client to GoTosocial for now. mastodon-async does not use the websocket endpoint to stream from the fedi, but the SSE endpoint instead. GoToSocial only implements the websocket endpoint for streaming operations.

Naturally, it supports both HTTP and HTTPS, through the use of rustls-tls by default. You can change to OpenSSL by modifying the features in Cargo.toml.

Future ambitions.

I'm interested in implementing any sort of social game, by which I understand games which involve social interaction, deception, prediction, or the like. In particular, I am interested in implementing the following games:

Some of these games need more interesting names.

It would be nice to run a nomic on the fedi, but that is a lot more than a bot can do by itself.

Bug reports, feature requests, code contributions and other feedback.

If you want to tell me something about the crate, the best ways are:

Change log.

  • V 0.1.3: dice can be rolled with the dice command, accepting an ndm optional parameter.
  • V 0.1.2: exponential backoff system for cases where the streaming API fails. Assorted typographical corrections.
  • V 0.1.1: set a loop around the toot streaming in case it errors out.
  • V 0.1.0: initial release.
Commit count: 0

cargo fmt