From bb82b2a34d91c8cdd373b66a6abdba885dc7bb92 Mon Sep 17 00:00:00 2001 From: wurstsalat Date: Tue, 29 Nov 2022 19:36:59 +0100 Subject: [regex_filter] Remove plugin Plugin is currently not compatible with Gajim 1.5 --- regex_filter/__init__.py | 1 - regex_filter/plugin-manifest.json | 20 ------ regex_filter/regex_filter.png | Bin 547 -> 0 bytes regex_filter/regex_filter.py | 130 -------------------------------------- 4 files changed, 151 deletions(-) delete mode 100644 regex_filter/__init__.py delete mode 100644 regex_filter/plugin-manifest.json delete mode 100644 regex_filter/regex_filter.png delete mode 100644 regex_filter/regex_filter.py diff --git a/regex_filter/__init__.py b/regex_filter/__init__.py deleted file mode 100644 index 2b5946a..0000000 --- a/regex_filter/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .regex_filter import RegexFilterPlugin diff --git a/regex_filter/plugin-manifest.json b/regex_filter/plugin-manifest.json deleted file mode 100644 index c7c4690..0000000 --- a/regex_filter/plugin-manifest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "authors": [ - "Yann Leboulanger " - ], - "description": "Filter incoming messages using regex.", - "homepage": "https://dev.gajim.org/gajim/gajim-plugins/wikis/RegexFilterPlugin", - "config_dialog": false, - "name": "Regex Filter", - "platforms": [ - "others", - "linux", - "darwin", - "win32" - ], - "requirements": [ - "gajim>=1.4.0" - ], - "short_name": "regex_filter", - "version": "1.4.2" -} \ No newline at end of file diff --git a/regex_filter/regex_filter.png b/regex_filter/regex_filter.png deleted file mode 100644 index a79ba10..0000000 Binary files a/regex_filter/regex_filter.png and /dev/null differ diff --git a/regex_filter/regex_filter.py b/regex_filter/regex_filter.py deleted file mode 100644 index 99310d1..0000000 --- a/regex_filter/regex_filter.py +++ /dev/null @@ -1,130 +0,0 @@ -# This file is part of Gajim. -# -# Gajim is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation; version 3 only. -# -# Gajim is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Gajim. If not, see . - -''' -Regex Filter plugin. - -:author: Yann Leboulanger -:since: 23th September 2011 -:copyright: Copyright (2011) Yann Leboulanger -:license: GPLv3 -''' - -import re - -from gajim.plugins import GajimPlugin - -from gajim.common import app -from gajim.common import ged -from gajim.command_system.framework import CommandContainer, command, doc -from gajim.command_system.implementation.hosts import ChatCommands -from gajim.command_system.implementation.hosts import GroupChatCommands -from gajim.command_system.implementation.hosts import PrivateChatCommands -from gajim.plugins.plugins_i18n import _ - - -class RegexFilterPlugin(GajimPlugin): - - def init(self): - self.description = _('Filter messages with regex') - self.config_dialog = None - - self.events_handlers = { - 'message-received': (ged.PREGUI1, self._on_message_received), - 'gc-message-received': (ged.PREGUI1, self._on_gc_message_received), - } - - self.create_rules() - - def activate(self): - FilterCommands.enable() - - def deactivate(self): - FilterCommands.disable() - - def create_rules(self): - self.rules = {} - for num, c in self.config.items(): - self.rules[int(num)] = [re.compile(c[0], re.MULTILINE), c[1]] - - def add_rule(self, search, replace): - if self.rules: - num = max(self.rules.keys()) + 1 - else: - num = 0 - self.config[str(num)] = [search, replace] - self.create_rules() - - def remove_rule(self, num): - if num in self.config: - del self.config[num] - self.create_rules() - return True - return False - - def get_rules(self): - return self.config - - def _nec_all(self, obj): - if not obj.msgtxt: - return - rules_num = sorted(self.rules.keys()) - for num in rules_num: - rule = self.rules[num] - obj.msgtxt = rule[0].sub(rule[1], obj.msgtxt) - - def _on_message_received(self, obj): - self._nec_all(obj) - - def _on_gc_message_received(self, obj): - self._nec_all(obj) - - -class FilterCommands(CommandContainer): - AUTOMATIC = False - HOSTS = ChatCommands, PrivateChatCommands, GroupChatCommands - - @command("add_filter", raw=True) - @doc(_("Add an incoming filter. First argument is the search regex, " - "second argument is the replace regex.")) - def add_filter(self, search, replace): - plugin = app.plugin_manager.get_active_plugin('regex_filter') - plugin.add_rule(search, replace) - return _('Added rule to replace %(search)s by %(replace)s' % { - 'search': search, 'replace': replace}) - - @command("remove_filter", raw=True) - @doc(_("Remove an incoming filter. Argument is the rule number. " - "See /list_rules command.")) - def remove_filter(self, num): - plugin = app.plugin_manager.get_active_plugin('regex_filter') - if plugin.remove_rule(num): - return _('Rule number %s removed' % num) - return _('Rule number %s does not exist' % num) - - @command("list_filters") - @doc(_("List incoming filters.")) - def list_filters(self): - plugin = app.plugin_manager.get_active_plugin('regex_filter') - rules = plugin.get_rules() - st = '' - for num, rule in rules.items(): - st += _('%(num)s: %(search)s -> %(replace)s') % { - 'num': num, - 'search': rule[0], - 'replace': rule[1]} + '\n' - if st: - return st[:-1] - else: - return _('No rule defined') -- cgit v1.2.3