plugin OTR: temporary potr monkey patch to work around a unicode bug, to be removed as soon as a potr fixed version is released (potr maintainer should do it soon)

This commit is contained in:
Goffi 2014-08-25 21:32:23 +02:00
commit ebf651226e

View file

@ -154,11 +154,28 @@ class OTR(object):
def __init__(self, host):
log.info(_(u"OTR plugin initialization"))
self._fixPotr() # FIXME: to be removed when potr will be fixed
self.host = host
self.context_managers = {}
host.trigger.add("MessageReceived", self.MessageReceivedTrigger, priority=100000)
host.trigger.add("sendMessage", self.sendMessageTrigger, priority=100000)
def _fixPotr(self):
# FIXME: potr fix for bad unicode handling
# this method monkeypatch it, must be removed when potr
# is fixed
def getDefaultQueryMessage(self, policy):
defaultQuery = '?OTRv{versions}?\nI would like to start ' \
'an Off-the-Record private conversation. However, you ' \
'do not have a plugin to support that.\nSee '\
'https://otr.cypherpunks.ca/ for more information.'
v = '2' if policy('ALLOW_V2') else ''
msg = defaultQuery.format(versions=v)
return msg.encode('ascii')
potr.context.Account.getDefaultQueryMessage = getDefaultQueryMessage
@defer.inlineCallbacks
def profileConnected(self, profile):
client = self.host.getClient(profile)