Commit b0fc66bd authored by Dicson's avatar Dicson
Browse files

UrlShortenerPlugin. gc support

parent 206a3634
[info] [info]
name: Url Shortener name: Url Shortener
short_name: url_shortener short_name: url_shortener
version: 0.3.1 version: 0.3.2
description: Plugin that allows users to shorten a long URL in messages. description: Plugin that allows users to shorten a long URL in messages.
For example, you can turn this link: For example, you can turn this link:
https://trac.gajim.org/timeline https://trac.gajim.org/timeline
......
...@@ -34,10 +34,15 @@ class UrlShortenerPlugin(GajimPlugin): ...@@ -34,10 +34,15 @@ class UrlShortenerPlugin(GajimPlugin):
'SHORTEN_OUTGOING': (False, ''),} 'SHORTEN_OUTGOING': (False, ''),}
self.events_handlers['message-outgoing'] = (ged.OUT_PRECORE, self.events_handlers['message-outgoing'] = (ged.OUT_PRECORE,
self.handle_outgoing_msg) self.handle_outgoing_msg)
self.events_handlers['gc-message-outgoing'] = (ged.OUT_PRECORE,
self.handle_outgoing_msg)
self.chat_control = None self.chat_control = None
self.controls = [] self.controls = []
self.is_active = None
def handle_outgoing_msg(self, event): def handle_outgoing_msg(self, event):
if not self.active:
return
if not event.message: if not event.message:
return return
if not self.config['SHORTEN_OUTGOING']: if not self.config['SHORTEN_OUTGOING']:
...@@ -94,6 +99,13 @@ class UrlShortenerPlugin(GajimPlugin): ...@@ -94,6 +99,13 @@ class UrlShortenerPlugin(GajimPlugin):
control.disconnect_from_chat_control() control.disconnect_from_chat_control()
self.controls.remove(control) self.controls.remove(control)
def activate(self):
self.active = True
def deactivate(self):
self.active = False
class Base(object): class Base(object):
def __init__(self, plugin, chat_control): def __init__(self, plugin, chat_control):
self.plugin = plugin self.plugin = plugin
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment