## 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: * [Spoof](https://en.wikipedia.org/wiki/Spoof_(game\)) (in progress on the spoof branch). * [Prisoner's dilemma](https://en.wikipedia.org/wiki/Prisoner%27s_dilemma). * [Centipede game](https://en.wikipedia.org/wiki/Centipede_game). * [Public goods game](https://en.wikipedia.org/wiki/Public_goods_game). * [Traveller's dilemma](https://en.wikipedia.org/wiki/Traveler%27s_dilemma). * [Ultimatum game](https://en.wikipedia.org/wiki/Ultimatum_game). * [Dictator game](https://en.wikipedia.org/wiki/Dictator_game) * [Mafia](https://en.wikipedia.org/wiki/Mafia_(party_game\)). * Unique lowest bid. * Guess 2/3 the average. * Predict the judgement. 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: * My fedi account, [@modulux@node.isonomia.net](https://node.isonomia.net/@modulux). * The [fossil repository](https://modulus.isonomia.net/pravda.cgi) for the project. * If you must, email me at modulus at isonomia dot net. ## 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.