plugins/summoner.js
function handler(notification) {
        debug('summoner received a mention notification!');
        return notification.getUser()
            .then((user) => {
                debug(`summoner responding to summons by ${user.name}`);
                const index = Math.floor(Math.random() * messages.length);
                const message = messages[index].replace(/%(\w+)%/g, (_, key) => {
                    let value = user[key];
                    if (key === 'name' && !value) {
                        value = user.username;
                    }
                    value = value || `%${key}%`;
                    if (typeof value !== 'string') {
                        value = `%${key}%`;
                    }
                    return value;
                });
                debug(`summoner replying with: ${message}`);
                return forum.Post.reply(notification.topicId, notification.postId, message);
            }).catch((err) => {
                forum.emit('error', err);
                return Promise.reject(err);
            });
    }
function handler(notification) {
        debug('summoner received a mention notification!');
        return notification.getUser()
            .then((user) => {
                debug(`summoner responding to summons by ${user.name}`);
                const index = Math.floor(Math.random() * messages.length);
                const message = messages[index].replace(/%(\w+)%/g, (_, key) => {
                    let value = user[key];
                    if (key === 'name' && !value) {
                        value = user.username;
                    }
                    value = value || `%${key}%`;
                    if (typeof value !== 'string') {
                        value = `%${key}%`;
                    }
                    return value;
                });
                debug(`summoner replying with: ${message}`);
                return forum.Post.reply(notification.topicId, notification.postId, message);
            }).catch((err) => {
                forum.emit('error', err);
                return Promise.reject(err);
            });
    }
function handler ( notification ) { debug ( 'summoner received a mention notification!' ) ; return notification . getUser ( ) . then ( ( user ) => { debug ( ` ${ user . name } ` ) ; const index = Math . floor ( Math . random ( ) * messages . length ) ; const message = messages [ index ] . replace ( / %(\w+)% / g , ( _ , key ) => { let value = user [ key ] ; if ( key === 'name' && ! value ) { value = user . username ; } value = value || ` ${ key } ` ; if ( typeof value !== 'string' ) { value = ` ${ key } ` ; } return value ; } ) ; debug ( ` ${ message } ` ) ; return forum . Post . reply ( notification . topicId , notification . postId , message ) ; } ) . catch ( ( err ) => { forum . emit ( 'error' , err ) ; return Promise . reject ( err ) ; } ) ; }
Handle a mention notification.

Choose a random message and reply with it

@param {Notification} notification Notification event to handle
@returns {Promise} Resolves when event is processed
Handle a mention notification .