parent
e3f0faf6d0
commit
73c8206cc7
2 changed files with 43 additions and 1 deletions
|
@ -202,7 +202,8 @@ class Core(object):
|
||||||
self.xmpp.add_event_handler("chatstate_gone", self.on_chatstate_gone)
|
self.xmpp.add_event_handler("chatstate_gone", self.on_chatstate_gone)
|
||||||
self.xmpp.add_event_handler("chatstate_inactive", self.on_chatstate_inactive)
|
self.xmpp.add_event_handler("chatstate_inactive", self.on_chatstate_inactive)
|
||||||
self.xmpp.add_event_handler("attention", self.on_attention)
|
self.xmpp.add_event_handler("attention", self.on_attention)
|
||||||
self.xmpp.register_handler(Callback('ALL THE STANZAS', connection.MatchAll(None), self.incoming_stanza))
|
self.all_stanzas = Callback('custom matcher', connection.MatchAll(None), self.incoming_stanza)
|
||||||
|
self.xmpp.register_handler(self.all_stanzas)
|
||||||
|
|
||||||
self.initial_joins = []
|
self.initial_joins = []
|
||||||
|
|
||||||
|
|
41
src/tabs.py
41
src/tabs.py
|
@ -39,6 +39,8 @@ import multiuserchat as muc
|
||||||
from theming import get_theme
|
from theming import get_theme
|
||||||
|
|
||||||
from sleekxmpp.xmlstream.stanzabase import JID
|
from sleekxmpp.xmlstream.stanzabase import JID
|
||||||
|
from sleekxmpp.xmlstream import matcher
|
||||||
|
from sleekxmpp.xmlstream.handler import Callback
|
||||||
from config import config
|
from config import config
|
||||||
from roster import RosterGroup, roster
|
from roster import RosterGroup, roster
|
||||||
from contact import Contact
|
from contact import Contact
|
||||||
|
@ -2584,6 +2586,10 @@ class XMLTab(Tab):
|
||||||
self.default_help_message = windows.HelpText("/ to enter a command")
|
self.default_help_message = windows.HelpText("/ to enter a command")
|
||||||
self.commands['close'] = (self.close, _("Usage: /close\nClose: Just close this tab."), None)
|
self.commands['close'] = (self.close, _("Usage: /close\nClose: Just close this tab."), None)
|
||||||
self.commands['clear'] = (self.command_clear, _("Usage: /clear\nClear: Clear the content of the current buffer."), None)
|
self.commands['clear'] = (self.command_clear, _("Usage: /clear\nClear: Clear the content of the current buffer."), None)
|
||||||
|
self.commands['reset'] = (self.command_reset, _("Usage: /reset\nReset: Reset the stanza filter."), None)
|
||||||
|
self.commands['filter_id'] = (self.command_filter_id, _("Usage: /filter_id <id>\nFilterId: Show only the stanzas with the id <id>."), None)
|
||||||
|
self.commands['filter_xpath'] = (self.command_filter_xpath, _("Usage: /filter_xpath <xpath>\nFilterXPath: Show only the stanzas matching the xpath <xpath>."), None)
|
||||||
|
self.commands['filter_xmlmask'] = (self.command_filter_xmlmask, _("Usage: /filter_xmlmask <xml mask>\nFilterXMLMask: Show only the stanzas matching the given xml mask."), None)
|
||||||
self.input = self.default_help_message
|
self.input = self.default_help_message
|
||||||
self.key_func['^T'] = self.close
|
self.key_func['^T'] = self.close
|
||||||
self.key_func['^I'] = self.completion
|
self.key_func['^I'] = self.completion
|
||||||
|
@ -2597,6 +2603,41 @@ class XMLTab(Tab):
|
||||||
self.text_win.toggle_lock()
|
self.text_win.toggle_lock()
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
|
def command_filter_xmlmask(self, arg):
|
||||||
|
"""/filter_xmlmask <xml mask>"""
|
||||||
|
try:
|
||||||
|
handler = Callback('custom matcher', matcher.MatchXMLMask(arg),
|
||||||
|
self.core.incoming_stanza)
|
||||||
|
self.core.xmpp.remove_handler('custom matcher')
|
||||||
|
self.core.xmpp.register_handler(handler)
|
||||||
|
except:
|
||||||
|
self.core.information('Invalid XML Mask', 'Error')
|
||||||
|
self.command_reset('')
|
||||||
|
|
||||||
|
def command_filter_id(self, arg):
|
||||||
|
"""/filter_id <id>"""
|
||||||
|
self.core.xmpp.remove_handler('custom matcher')
|
||||||
|
handler = Callback('custom matcher', matcher.MatcherId(arg),
|
||||||
|
self.core.incoming_stanza)
|
||||||
|
self.core.xmpp.register_handler(handler)
|
||||||
|
|
||||||
|
def command_filter_xpath(self, arg):
|
||||||
|
"""/filter_xpath <xpath>"""
|
||||||
|
try:
|
||||||
|
handler = Callback('custom matcher', matcher.MatchXPath(
|
||||||
|
arg.replace('%n', self.core.xmpp.default_ns)),
|
||||||
|
self.core.incoming_stanza)
|
||||||
|
self.core.xmpp.remove_handler('custom matcher')
|
||||||
|
self.core.xmpp.register_handler(handler)
|
||||||
|
except:
|
||||||
|
self.core.information('Invalid XML Path', 'Error')
|
||||||
|
self.command_reset('')
|
||||||
|
|
||||||
|
def command_reset(self, arg):
|
||||||
|
"""/reset"""
|
||||||
|
self.core.xmpp.remove_handler('custom matcher')
|
||||||
|
self.core.xmpp.register_handler(self.core.all_stanzas)
|
||||||
|
|
||||||
def on_slash(self):
|
def on_slash(self):
|
||||||
"""
|
"""
|
||||||
'/' is pressed, activate the input
|
'/' is pressed, activate the input
|
||||||
|
|
Loading…
Reference in a new issue