DonJS

a library to create mastodon's bots in js
授权协议 MIT License
开发语言 Python
所属分类 应用工具、 IM/聊天/语音工具
软件类型 开源软件
地区 不详
投 递 者 姬博瀚
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

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

Examples

One of the basic examples on how to use this library is

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 fromSettings -> 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

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.

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!");
});

相关阅读

相关文章

相关问答

相关文档