[Pidgin] #14935: receiving-chat-msg doesn't seem to catch system messages
Pidgin
trac at pidgin.im
Fri Mar 2 09:24:22 EST 2012
#14935: receiving-chat-msg doesn't seem to catch system messages
-------------------------+--------------------------------------------------
Reporter: mcepl | Owner:
Type: enhancement | Status: closed
Milestone: | Component: libpurple
Version: 2.7.9 | Resolution:
Keywords: |
-------------------------+--------------------------------------------------
Comment(by mcepl):
Even when using writing-chat-msg and I can see that regular expression
matches incoming messages, they are still not cancelled:
{{{
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Script for filtering incoming chat messages in Pidgin.
Copyright (c) 2011, Matěj Cepl <mcepl-at-redhat-dot-com>
Permission is hereby granted, free of charge, to any person obtaining a
copy of
this software and associated documentation files (the "Software"), to deal
in
the Software without restriction, including without limitation the rights
to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of
the Software, and to permit persons to whom the Software is furnished to
do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import, unicode_literals, print_function
import re
import logging
import dbus, dbus.mainloop.glib, gobject
__author__ = "Matěj Cepl <mcepl|at|redhat|dot|com>"
__version__ = "0.0.2"
HIDE_CHAT_RE = re.compile(r'(\S+) je teď znám jako (\S+)', re.UNICODE)
logging.basicConfig(level=logging.DEBUG)
def should_cancel_chat_message(account, sender, message, conversation,
flags):
"""Callback function for writing-chat-msg signal.
According to http://developer.pidgin.im/doxygen/dev/html\
/conversation-signals.html#writing-chat-msg callback returns:
TRUE if the message should be canceled, or FALSE otherwise.
"""
res = bool(HIDE_CHAT_RE.search(unicode(message)))
logging.debug("in conversation %s sender %s (flags %s, RE=%s) is
saying:\n%s",
conversation, sender, flags, res, message)
return res
if __name__ == "__main__":
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(should_cancel_chat_message,
dbus_interface="im.pidgin.purple.PurpleInterface",
signal_name="WritingChatMsg")
loop = gobject.MainLoop()
loop.run()
}}}
--
Ticket URL: <http://developer.pidgin.im/ticket/14935#comment:3>
Pidgin <http://pidgin.im>
Pidgin
More information about the Tracker
mailing list