https://github.com/blacksmithop/mafiaggbot
Mafia.gg Bot
https://github.com/blacksmithop/mafiaggbot
Last synced: 11 months ago
JSON representation
Mafia.gg Bot
- Host: GitHub
- URL: https://github.com/blacksmithop/mafiaggbot
- Owner: blacksmithop
- Created: 2021-05-16T05:42:41.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-20T11:09:57.000Z (over 1 year ago)
- Last Synced: 2025-06-08T10:06:12.970Z (12 months ago)
- Language: Python
- Homepage: https://mafia.abhinavkm.com/
- Size: 1.43 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# MafiaggBot



[Dashboard](https://mafiaggstats.netlify.app/)
[API Docs](https://blacksmithop.github.io/MafiaggBot/)
## Usage
---
```shell
pip install -U mafiagg
```
```shell
pip install -U python-dotenv
```
`python-dotenv` lets you pass a `.env` file with your mafia.gg credentials
```
MAFIA_USERNAME=username
MAFIA_PASSWORD=password
```
If you wish to enable the chatbot, set these variables
```
LLM_PROVIDER=
GOOGLE_API_KEY=
OLLAMA_URL=
AGENT_VERBOSE=
```
`LLM_PROVIDER` can be`ollama`, `google` or `openai`
> TODO: Detailed instructions for LLM's
### Example
```python
from mafiagg.client import Bot
from mafiagg.credential_manager import CredentialManager
from sys import exit
auth = CredentialManager()
bot = Bot(auth=auth, command_prefix="$")
try:
bot.run()
except KeyboardInterrupt:
exit(0)
```
> When you run the bot for the first time, it will download some metadata it a `./data/` folder.
---
### Features
- [x] Rooms
- [x] List rooms
- [x] Make private/public
- [x] Become player/spectator
- [x] Do afk check
- [x] Do afk check
- [x] Do ready check
- [ ] Edit room options
- [x] Rename room
- [x] Create new room
- [x] Only create room when game end
- [x] Decks
- [x] Get deck by name
- [x] Set deck by name
- [x] Use random deck
- [x] Setups
- [x] Get setup by name
- [x] Set setup by code
- [x] Set setup by name
- [ ] Get current setup code
- [x] Roles
- [x] Get role by name
- [x] Cleanup role descriptions, alignment with validator
- [x] Commands
- [x] Custom command names
- [x] Command docs
- [x] Bot Client
- [x] Authentication
- [x] Help command
- [ ] Formatted / multi-message help command
- [x] Host only commands
- [ ] Host can add admins
- [x] AI
- [x] Chatbot
- [x] Multiple LLM support
- [x] Tool usage with Langgraph
- [] Robust memory
- [] Play games with AI
- [] Document in game action payloads
- [] Keep player game statistics
- [] Create REST Api for [mafiaggstats](https://mafiaggstats.netlify.app/)
### Tasklist
- [ ] Do not allow creation of new room unless game is over
- [ ] Lookup in game Items
- [x] Edit room options
- [ ] Implement conversion of role dictionary to setup codes
- [ ] Return character info (for decks in next message)
- [ ] Better commands (sub-commands!)
- [ ] Better doc strings using decorators
- [ ] Join other rooms on request
- [ ] Check if bot can handle concurrent games, keep session!
- [ ] Keep role cache based on room id
- [ ] Allow for `super().__init__` calls
- [x] Gracefully end session
- [ ] End event loops, close websocket connection
- [x] When exiting call DELETE on `user-session` (cookie invalidation)
## Development
Clone the repo
```shell
git clone https://github.com/blacksmithop/MafiaggBot
cd MafiaggBot
```
---
Install the dependencies
```shell
python3 -m pip install -r requirements.txt
```