summaryrefslogtreecommitdiff
path: root/bosd.py
diff options
context:
space:
mode:
Diffstat (limited to 'bosd.py')
-rw-r--r--bosd.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/bosd.py b/bosd.py
index 4a241be..d678754 100644
--- a/bosd.py
+++ b/bosd.py
@@ -1,7 +1,9 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2# -*- coding: utf-8 -*- 2# -*- coding: utf-8 -*-
3 3
4import socket 4import urllib
5import urllib2
6
5import weechat 7import weechat
6 8
7#### CONFIG #### 9#### CONFIG ####
@@ -14,21 +16,28 @@ notify_channels = [
14 "Exile.#pichove" 16 "Exile.#pichove"
15 ] 17 ]
16 18
17connections = [ {'sbosdd_ip': '127.0.0.1', 19connections = [ {'bosd_url': 'https://127.0.0.1:9999/npush/',
18 'sbosdd_port': 9999}, 20 'bosd_password': '1234'},
19# {'sbosdd_ip': "10.0.0.2", 21
20# 'sbosdd_port': 9999} 22# {'bosd_url': 'https://pichove.org:9999/npush/',
23# 'bosd_port': 9999,
24# 'bosd_password': 'foo'},
21 ] 25 ]
22################ 26################
23 27
24def bosd_send_xosd_message(message): 28__VERSION__ = '2.0'
29
30def bosd_send_message(header='', message=''):
25 for conn in connections: 31 for conn in connections:
26 try: 32 try:
33 conn['nheader'] = header # notification header
34 conn['nmessage'] = message # notification message
35
36 data = urllib.urlencode(conn)
37
38 req = urllib2.Request(url, data)
39 urllib2.urlopen(req)
27 #weechat.prnt("", message) 40 #weechat.prnt("", message)
28 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
29 s.connect((conn['sbosdd_ip'], conn['sbosdd_port']))
30 s.send(message)
31 s.close()
32 except: 41 except:
33 continue 42 continue
34 43
@@ -44,7 +53,7 @@ def bosd_command(data, buffer, args):
44 enabled = False 53 enabled = False
45 weechat.prnt(weechat.current_buffer(), "bosd off") 54 weechat.prnt(weechat.current_buffer(), "bosd off")
46 else: 55 else:
47 bosd_send_xosd_message(args) 56 bosd_send_message('BOSD generic', args)
48 57
49 return weechat.WEECHAT_RC_OK 58 return weechat.WEECHAT_RC_OK
50 59