• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

HedariKun/DonJS: a library to create mastodon's bots in js

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

HedariKun/DonJS

开源软件地址(OpenSource Url):

https://github.com/HedariKun/DonJS

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

DonJS CodeFactor npm version

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

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



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap