chatgpt-plugin/utils/tools/EliMovieTool.js
2023-10-14 13:07:01 +08:00

44 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { AbstractTool } from './AbstractTool.js'
export class EliMovieTool extends AbstractTool {
name = 'currentHotMovies'
parameters = {
properties: {
yesOrNo: {
type: 'string',
description: 'check or not'
}
},
required: ['yesOrNo']
}
description = 'Useful when you want to check out the current hot movies'
func = async function (opts, e) {
let { yesOrNo } = opts
if (yesOrNo === 'no') {
return 'tell user why you don\'t want to check'
}
if (e.at === e.bot.uin) {
e.at = null
}
e.atBot = false
let avocado
try {
// eslint-disable-next-line camelcase
let { AvocadoMovie } = await import('../../../avocado-plugin/apps/avocadoMovie.js')
avocado = new AvocadoMovie(e)
} catch (err1) {
return 'the user didn\'t install avocado-plugin. suggest him to install'
}
try {
// eslint-disable-next-line new-cap
await avocado.getHotMovies(e)
return 'notify the user that the movie has been sent to them and they can obtain more information by sending commands displayed in the picture. you dont need to search for additional information to reply! just simply inform them that you have completed your task!!!'
} catch (err) {
logger.warn(err)
return 'failed due to unknown error'
}
}
}