Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doug-wade/matchbot
A pluggable Lemmy bot for conducting match threads
https://github.com/doug-wade/matchbot
Last synced: 17 days ago
JSON representation
A pluggable Lemmy bot for conducting match threads
- Host: GitHub
- URL: https://github.com/doug-wade/matchbot
- Owner: doug-wade
- Created: 2024-01-21T03:14:10.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-04-11T14:13:40.000Z (9 months ago)
- Last Synced: 2024-11-01T09:34:21.694Z (2 months ago)
- Language: JavaScript
- Size: 268 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# Matchbot
Matchbot is a pluggable Lemmy bot framework for making matchbots for various sports. See `packages/example` for an example of how to use the bot framework.
## Creating bots
### Example
Here is a minimal example of a bot that posts match threads to the Reign FC lemmy community on `lemmy.world` for Reign FC matches using the soccer plugin.
```javascript
import { createBot } from '@matchbot/core';
import soccer from '@matchbot/soccer';createBot({
plugins: [
{
plugin: soccer,
config: { teamId: 3002 },
community_id: 86091,
},
]
});
```## Creating plugins
Here is a minimal example of a plugin that fetches data from an api
```javascript
import { Plugin } from '@matchbot/core';export default class MatchbotExamplePlugin extends Plugin {
#baseUrl = "";
name = 'example';async fixtures() {
const response = this.fetch(`${baseUrl}/fixtures`);return response.fixtures.map(fixture => {
new Thread({
id: fixture.id,
name: fixture.name,
date: fixture.timestamp,
args: fixture,
completed: fixture.completed,
});
});
}
async preview() {
const response = this.fetch(`${baseUrl}/preview`);return new Post({
name: response.name,
body: response.body
});
}async thread() {
const response = this.fetch(`${baseUrl}/thread`);return '';
}
}
```