7. Mentions¶
Depending on the backend used, users can mention and notify other users by using a special syntax like @gbin. With this feature, a plugin can listen to the mentioned users in the chat.
7.1. How to use it¶
Here is an example to listen to every mention and report them back on the chat.
from errbot import BotPlugin
class PluginExample(BotPlugin):
def callback_mention(self, message, mentioned_people):
for identifier in mentioned_people:
self.send(message.frm, 'User %s has been mentioned' % identifier)
7.2. Identifying if the bot itself has been mentioned¶
Simply test the presence of the bot identifier within the mentioned_people:
from errbot import BotPlugin
class PluginExample(BotPlugin):
def callback_mention(self, message, mentioned_people):
if self.bot_identifier in mentioned_people:
self.send(message.frm, 'Errbot has been mentioned !')
Previous: 6. Presence
|
Next: 8. Persistence