const { Wechaty, log} = require("wechaty");
const { WordsPerDay} = require("words-per-day");
const bot = new Wechaty();
bot
.use(WordsPerDay(/*config*/))
.on("login", (user) => log.info("Bot", `${user.name()} logined`))
.on("logout", (user) => log.info("Bot", `${user.name()} logouted`))
.on("error", (e) => log.info("Bot", "error: %s", e));
bot.start();
You can implement the following function to use self-defined source of the data
export interface getWordsFunc {
(): Promise<string>;
}
You can refer to the following links if you don't know JsonPath expressions:
async function getDailyEnglish(){
return getWords(
Theme.JSON,
'https://apiv3.shanbay.com/weapps/dailyquote/quote/',
['content', 'translation']
);
}
const config = {
rooms: ["Group"],// the name of targeted group chat
sendTime: "13:02",// Time for automatic delivery of the daily meaasge
trigger: "Hello",// Trigger word for the delivery of the daily meaasge
imageDir: 'image',// Local directory to store images
imageStyle: 0, // Style of images to be sent, only support 0 and 1 for now
name: 'DailyEnglish',// the name of the bot
func: getDailyEnglish // the name of function which specify data sources
};
For each message, the image color changes.
The specific style of the image is as follows, showing the user's avatar and name