xmppjs-chat-bot
Version:
Server-side XMPP chat bot
36 lines • 1.34 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.HandlerRespond = void 0;
const abstract_1 = require("./abstract");
const reference_1 = require("../reference");
const handlers_directory_1 = require("../handlers_directory");
class HandlerRespond extends abstract_1.Handler {
constructor(id, room, options) {
super(id, room, options);
this.txt ?? (this.txt = 'Yes {{NICK}}?');
this.roomMentionned = (stanza, fromUser) => {
if (!stanza.from) {
return;
}
const mention = reference_1.ReferenceMention.mention(this.txt, fromUser.jid, '{{NICK}}');
this.room.sendGroupchat(mention.txt, mention.references).catch((err) => { this.logger.error(err); });
};
}
loadOptions(options) {
if (typeof options !== 'object') {
return;
}
if (('txt' in options) && (typeof options.txt === 'string')) {
this.txt = options.txt;
}
}
start() {
this.room.on('room_mentionned', this.roomMentionned);
}
stop() {
this.room.off('room_mentionned', this.roomMentionned);
}
}
exports.HandlerRespond = HandlerRespond;
handlers_directory_1.HandlersDirectory.singleton().register('respond', HandlerRespond);
//# sourceMappingURL=respond.js.map
;