Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hedarikun/donjs
a library to create mastodon's bots in js
https://github.com/hedarikun/donjs
bot js library mastodon
Last synced: about 2 months ago
JSON representation
a library to create mastodon's bots in js
- Host: GitHub
- URL: https://github.com/hedarikun/donjs
- Owner: HedariKun
- License: mit
- Created: 2018-10-06T11:05:04.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-29T14:00:00.000Z (almost 6 years ago)
- Last Synced: 2024-04-13T14:28:47.953Z (8 months ago)
- Topics: bot, js, library, mastodon
- Language: JavaScript
- Homepage:
- Size: 98.6 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DonJS ![CodeFactor](https://www.codefactor.io/repository/github/hedarikun/donjs/badge) [![npm version](https://badge.fury.io/js/donjs.svg)](https://badge.fury.io/js/donjs)
DonJS is a javascript library to create Mastodon bots# How to start
1. to start using DonJS you need to create a new folder for your bot
2. then you need to run terminal or CMD in that directory
3. then run ```npm init -y``` command.
4. after that you need to install the library by running ```npm install donjs```to visit the documentation [click here](https://www.github.com/hedarikun/donjs/wiki)
# Examples
One of the basic examples on how to use this library is
```js
const donjs = require("donjs");
const client = new donjs("your bot token", "your mastodon instance base url");client.sendStatus("hello world");
```
This example is to show, how to send hello world status using donjs.
you can get the token from
Settings -> Development -> create a new application then choose whatever name you want then press Submit -> copy the applications access token.another example that explains how you can listen for the public statuses that people create or delete
```js
const donjs = require("donjs");
const client = new donjs("your bot token", "your mastodon instance base url");client.listenForStatuses();
client.on("onStatus", status => {
console.log("status created!");
});client.on("onStatusDelete", id => {
console.log("status deleted!");
});
```you can also listen for notifications.
```js
const donjs = require("donjs");
const client = new donjs("your bot token", "your mastodon instance base url");client.listenForNotifications();
client.on("onNotification", notification => {
console.log("there is a new notification!");
});
```