[英]Using Whatsapp-web.js and MyanimeList api to send news on group
正如标题描述我的问题一样,我最近才开始使用 whatsapp-web.js 开发 WhatsApp Bot,但问题是我不擅长阅读文档,所以我的问题是:
Does anyone knows how to send anime and manga latest news to whatsapp using an api, like MyAnimeList Api or MYANIMENEWS api, or any other api
我尝试过的代码如下:
client.on('message', async message => {
const content = message.body
if (content === "anime-news") {
const animeDb = await axios("https://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime=id")
.then(res => res.data)
client.sendMessage(message.from, await MessageMedia.fromUrl('animeDb.url'))
});
您可以尝试使用这种算法来解决您的问题
function hash(string, len=10){return result} // hash the content let currentHash; let chatSubsCode = ["12312@c.us","1231231@g.us","etc"]; const delay = 1000; setInterval(()=>{ // some code to request data let data = "some response"; // <- warn: it will spam API request let hashedData = hash(data); if(currentHash==hashedData) return; currentHash = hashedData; // send for(chatid of chatSubsCode) client.sendMessage(chatid, data); },delay)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.