File: mentions.rst

package info (click to toggle)
errbot 6.2.0%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,796 kB
  • sloc: python: 11,557; makefile: 164; sh: 97
file content (37 lines) | stat: -rw-r--r-- 1,070 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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.

How to use it
-------------

Here is an example to listen to every mention and report them back on the chat.

.. code-block:: python

    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)


Identifying if the bot itself has been mentioned
------------------------------------------------

Simply test the presence of the bot identifier within the `mentioned_people`:

.. code-block:: python

    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 !')