summaryrefslogtreecommitdiff
path: root/bosd.py
diff options
context:
space:
mode:
Diffstat (limited to 'bosd.py')
-rw-r--r--bosd.py101
1 files changed, 0 insertions, 101 deletions
diff --git a/bosd.py b/bosd.py
deleted file mode 100644
index d678754..0000000
--- a/bosd.py
+++ /dev/null
@@ -1,101 +0,0 @@
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4import urllib
5import urllib2
6
7import weechat
8
9#### CONFIG ####
10enabled = True
11
12notify_channels = [
13 "RedpillLinpro.#python",
14 "Exile.#hin",
15 "RedpillLinpro.#adult",
16 "Exile.#pichove"
17 ]
18
19connections = [ {'bosd_url': 'https://127.0.0.1:9999/npush/',
20 'bosd_password': '1234'},
21
22# {'bosd_url': 'https://pichove.org:9999/npush/',
23# 'bosd_port': 9999,
24# 'bosd_password': 'foo'},
25 ]
26################
27
28__VERSION__ = '2.0'
29
30def bosd_send_message(header='', message=''):
31 for conn in connections:
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)
40 #weechat.prnt("", message)
41 except:
42 continue
43
44 return True
45
46
47def bosd_command(data, buffer, args):
48 global enabled
49 if args == 'on':
50 enabled = True
51 weechat.prnt(weechat.current_buffer(), "bosd on")
52 elif args == 'off':
53 enabled = False
54 weechat.prnt(weechat.current_buffer(), "bosd off")
55 else:
56 bosd_send_message('BOSD generic', args)
57
58 return weechat.WEECHAT_RC_OK
59
60
61def bosd_privmsg_handler(data, signal, signal_data):
62 if not enabled:
63 return weechat.WEECHAT_RC_OK
64
65 prvmsg_dict = weechat.info_get_hashtable("irc_message_parse",
66 { "message": signal_data })
67
68
69 server = signal.split(",")[0]
70
71 # channel = signal_data.split(":")[-1]
72 # my_nick = weechat.info_get("irc_nick_from_host", signal_data)
73
74 my_nick = weechat.info_get("irc_nick", server)
75 channel = prvmsg_dict['arguments'].split(":")[0].strip()
76 nick = prvmsg_dict['nick']
77 message = ':'.join(prvmsg_dict['arguments'].split(':')[1:]).strip()
78
79 if (my_nick in message) or ('{0}.{1}'.format(server,channel) in notify_channels):
80 template_msg = '{0} @ {1} - {2}: {3}'.format(channel,
81 server,
82 nick,
83 message)
84 bosd_send_xosd_message(template_msg)
85
86 if my_nick in channel:
87 template_msg = '{0} @ {1}: {2}'.format(nick, server, message)
88 bosd_send_xosd_message(template_msg)
89
90 #my_str = "%s - %s - %s - %s" % (my_nick, server, channel, message)
91 #weechat.prnt("", my_str)
92
93 return weechat.WEECHAT_RC_OK
94
95
96
97weechat.register('bosd', 'Simeon Simeonov', '1.0', 'GPL3', 'Socket notification script', "", "")
98weechat.hook_command("bosd", "bosd on off toggle", "<on | off>", "description...", "None", "bosd_command", "")
99weechat.hook_signal("*,irc_in2_privmsg", "bosd_privmsg_handler", "")
100
101weechat.prnt("", "bosd initiated!")