Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
poezio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
178
Issues
178
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
poezio
Commits
558ef877
Commit
558ef877
authored
Mar 09, 2016
by
Frédéric Meynadier
Committed by
louiz’
Mar 09, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ability to notify new messages in MUCs
parent
bfbd61c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
plugins/simple_notify.py
plugins/simple_notify.py
+27
-0
No files found.
plugins/simple_notify.py
View file @
558ef877
...
...
@@ -43,6 +43,17 @@ are used to erase/delete/kill the notification after a certain
delay. In our example it is used to display an empty message in our
xmobar, erasing the notification after 3 seconds.
Third example:
.. code-block:: ini
[simple_notify]
command = notify-send -i /path/to/poezio/data/poezio_80.png "New message from %(from)s" "%(body)s"
muc_too = true
If present and set to ``True``, the ``muc_too`` option will also trigger a
notification when a new message arrives on a Multi User Chat you've joined.
.. note:: If you set the :term:`exec_remote` option to ``true`` into the
main configuration file, the command will be executed remotely
(as explained in the :ref:`link-plugin` plugin help).
...
...
@@ -62,17 +73,25 @@ Options defined
after_command
Command to run after :term:`delay`. You probably want to clean up things.
muc_too
Boolean indicating whether new messages in Multi User Chat rooms should
trigger a notification or not.
"""
from
plugin
import
BasePlugin
from
xhtml
import
get_body_from_message_stanza
from
timed_events
import
DelayedEvent
import
shlex
import
common
class
Plugin
(
BasePlugin
):
def
init
(
self
):
self
.
api
.
add_event_handler
(
'private_msg'
,
self
.
on_private_msg
)
self
.
api
.
add_event_handler
(
'conversation_msg'
,
self
.
on_conversation_msg
)
if
self
.
config
.
get
(
'muc_too'
,
False
):
self
.
api
.
add_event_handler
(
'muc_msg'
,
self
.
on_muc_msg
)
self
.
api
.
add_event_handler
(
'highlight'
,
self
.
on_highlight
)
def
on_private_msg
(
self
,
message
,
tab
):
...
...
@@ -87,6 +106,14 @@ class Plugin(BasePlugin):
fro
=
message
[
'from'
].
bare
self
.
do_notify
(
message
,
fro
)
def
on_muc_msg
(
self
,
message
,
tab
):
fro
=
message
[
'from'
].
bare
# Prevent old messages to be notified
# find_delayed_tag(message) returns (True, the datetime) or
# (False, None)
if
not
common
.
find_delayed_tag
(
message
)[
0
]:
self
.
do_notify
(
message
,
fro
)
def
do_notify
(
self
,
message
,
fro
):
body
=
get_body_from_message_stanza
(
message
,
use_xhtml
=
False
)
if
not
body
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment