summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2017-05-14 12:59:19 +0200
committerSimeon Simeonov2017-05-14 12:59:19 +0200
commit0680cabd7c963586f732512eb622c85a68865233 (patch)
tree4e0dd9d71652f52413b29b7fadabd29fd6ea0431
parent06136d21f73eb26c8fc516b257345a87540ed658 (diff)
Fix a few encoding/decoding and OSD timeout bugs
-rwxr-xr-xbeinc_server.py13
-rw-r--r--beinc_weechat.py15
2 files changed, 17 insertions, 11 deletions
diff --git a/beinc_server.py b/beinc_server.py
index 3d9ff35..284f657 100755
--- a/beinc_server.py
+++ b/beinc_server.py
@@ -125,9 +125,16 @@ class BEINCInstance(object):
125 sys.exit(errno.EPERM) 125 sys.exit(errno.EPERM)
126 try: 126 try:
127 self.__osd_notification = pynotify.Notification(' ') 127 self.__osd_notification = pynotify.Notification(' ')
128 self.__osd_notification.timeout = 1000 * int(instance_dict.get( 128 if PY3:
129 'osd_timeout', 5)) 129 self.__osd_notification.timeout = 1000 * int(
130 self.__osd_notification.set_category('im.received') 130 instance_dict.get('osd_timeout', 5))
131 self.__osd_notification.set_category('im.received')
132 else:
133 self.__osd_notification.set_timeout(
134 1000 * int(instance_dict.get('osd_timeout', 5)))
135 self.__osd_notification.set_property(
136 'app_name',
137 '{0} {1}'.format(sys.argv[0], __version__))
131 self.__osd_type = BEINC_OSD_TYPE_PYNOTIFY 138 self.__osd_type = BEINC_OSD_TYPE_PYNOTIFY
132 except Exception as e: 139 except Exception as e:
133 sys.stderr.write( 140 sys.stderr.write(
diff --git a/beinc_weechat.py b/beinc_weechat.py
index a897a7d..cc92301 100644
--- a/beinc_weechat.py
+++ b/beinc_weechat.py
@@ -312,15 +312,14 @@ class WeechatTarget(object):
312 values: dict 312 values: dict
313 template: str 313 template: str
314 """ 314 """
315 template = unicode(template)
316 timestamp = datetime.datetime.now().strftime(self.__timestamp_format) 315 timestamp = datetime.datetime.now().strftime(self.__timestamp_format)
317 replacements = {u'%S': values['server'].decode('utf-8'), 316 replacements = {'%S': values['server'],
318 u'%s': values['source_nick'].decode('utf-8'), 317 '%s': values['source_nick'],
319 u'%c': values['channel'].decode('utf-8'), 318 '%c': values['channel'],
320 u'%m': values['message'].decode('utf-8'), 319 '%m': values['message'],
321 u'%t': timestamp.decode('utf-8'), 320 '%t': timestamp,
322 u'%p': u'BEINC', 321 '%p': u'BEINC',
323 u'%n': values['own_nick'].decode('utf-8')} 322 '%n': values['own_nick']}
324 for key, value in replacements.items(): 323 for key, value in replacements.items():
325 template = template.replace(key, value) 324 template = template.replace(key, value)
326 return template.encode('utf-8') 325 return template.encode('utf-8')