[Pidgin] #14935: receiving-chat-msg doesn't seem to catch system messages

Pidgin trac at pidgin.im
Wed Feb 15 07:44:30 EST 2012


#14935: receiving-chat-msg doesn't seem to catch system messages
------------------+---------------------------------------------------------
Reporter:  mcepl  |        Type:  enhancement
  Status:  new    |   Component:  libpurple  
 Version:  2.7.9  |    Keywords:             
------------------+---------------------------------------------------------
 I have on IRC (especially the internal company one) tons of messages like
 "tpelka|mtg je teď znám jako tpelka|lunch" (key phrase is a Czech
 translation of "is now known as"). I would like to avoid them, so I tried
 to create this simple python script:
 {{{
 # -*- 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.
 """

 import re
 import logging
 import dbus, gobject
 from dbus.mainloop.glib import DBusGMainLoop

 __author__ = "Matěj Cepl <mcepl|at|redhat|dot|com>"
 __version__ = "0.0.1"

 HIDE_CHAT_RE=re.compile(r'(\S+) je teď znám jako (\S+)', re.UNICODE)
 logging.basicConfig(level=logging.DEBUG)

 def should_allow_chat_message(account, sender, message, conversation,
 flags):
     loggin.debug("in conversation %s sender %s (flags %s, RE=%s) is
 saying:\n%s",
         conversation, sender, flags,
 HIDE_CHAT_RE.search(unicode(message)),
         message)
     return not HIDE_CHAT_RE.search(unicode(message))

 if __name__=="__main__":
         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
         bus = dbus.SessionBus()

         bus.add_signal_receiver(should_allow_chat_message,
 dbus_interface="im.pidgin.purple.PurpleInterface",
                                 signal_name="ReceivingChatMsg")
         loop = gobject.MainLoop()
         loop.run()
 }}}

 However, even when it is running it doesn't show ANY system messages
 (flags in the log are either 1 or 2, never anything more than that).

-- 
Ticket URL: <http://developer.pidgin.im/ticket/14935>
Pidgin <http://pidgin.im>
Pidgin


More information about the Tracker mailing list