diff options
| author | Simeon Simeonov | 2013-01-25 21:54:44 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2013-01-25 21:54:44 +0100 |
| commit | 3fcb4d9fbcc80b7bb2669eb03f838bb15fa9d5c6 (patch) | |
| tree | 564af611e2d925eb4cf4e781885ce154a712b984 /bosd.py | |
| parent | 5c2becae337ea7e2bcebec2912e4626d853b16aa (diff) | |
Some mess added
Diffstat (limited to 'bosd.py')
| -rw-r--r-- | bosd.py | 31 |
1 files changed, 20 insertions, 11 deletions
| @@ -1,7 +1,9 @@ | |||
| 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | 3 | ||
| 4 | import socket | 4 | import urllib |
| 5 | import urllib2 | ||
| 6 | |||
| 5 | import weechat | 7 | import weechat |
| 6 | 8 | ||
| 7 | #### CONFIG #### | 9 | #### CONFIG #### |
| @@ -14,21 +16,28 @@ notify_channels = [ | |||
| 14 | "Exile.#pichove" | 16 | "Exile.#pichove" |
| 15 | ] | 17 | ] |
| 16 | 18 | ||
| 17 | connections = [ {'sbosdd_ip': '127.0.0.1', | 19 | connections = [ {'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 | ||
| 24 | def bosd_send_xosd_message(message): | 28 | __VERSION__ = '2.0' |
| 29 | |||
| 30 | def 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 | ||
