equal
deleted
inserted
replaced
27 NOTIFY_TIMEOUT=4000 |
27 NOTIFY_TIMEOUT=4000 |
28 |
28 |
29 contact_map = { } |
29 contact_map = { } |
30 # Nickname used for the notification |
30 # Nickname used for the notification |
31 |
31 |
|
32 contact_custom_msg = { } |
|
33 # Message used for the notification |
|
34 |
32 online_alerts = { } |
35 online_alerts = { } |
33 # 0: disabled 1: normal notification 2: permanent notify box |
36 # 0: disabled 1: normal notification 2: permanent notify box |
34 |
37 |
35 voicemap = { } |
38 voicemap = { } |
36 # Specify the name pronounced by espeak |
39 # Specify the name pronounced by espeak |
53 |
56 |
54 config = ConfigParser.ConfigParser() |
57 config = ConfigParser.ConfigParser() |
55 config.read(CONFFILE) |
58 config.read(CONFFILE) |
56 |
59 |
57 contact_map.clear() |
60 contact_map.clear() |
|
61 contact_custom_msg.clear() |
58 online_alerts.clear() |
62 online_alerts.clear() |
59 voicemap.clear() |
63 voicemap.clear() |
60 blacklist.clear() |
64 blacklist.clear() |
61 |
65 |
62 if config.has_option("Notifications", "notify"): |
66 if config.has_option("Notifications", "notify"): |
73 opt['snd_cmd_msg_in'] = config.get("Notifications", "snd_cmd_msg_in") |
77 opt['snd_cmd_msg_in'] = config.get("Notifications", "snd_cmd_msg_in") |
74 |
78 |
75 if config.has_section("Contacts"): |
79 if config.has_section("Contacts"): |
76 for id in config.options("Contacts"): |
80 for id in config.options("Contacts"): |
77 contact_map[id] = config.get("Contacts", id) |
81 contact_map[id] = config.get("Contacts", id) |
|
82 |
|
83 if config.has_section("Contact_Customized_Messages"): |
|
84 for id in config.options("Contact_Customized_Messages"): |
|
85 contact_custom_msg[id] = config.get("Contact_Customized_Messages", id) |
78 |
86 |
79 if config.has_section("Alerts"): |
87 if config.has_section("Alerts"): |
80 for id in config.options("Alerts"): |
88 for id in config.options("Alerts"): |
81 online_alerts[id] = int(config.get("Alerts", id)) |
89 online_alerts[id] = int(config.get("Alerts", id)) |
82 |
90 |
141 if event == 'MSG' and arg1 == 'IN': |
149 if event == 'MSG' and arg1 == 'IN': |
142 import os |
150 import os |
143 |
151 |
144 jid = arg2 |
152 jid = arg2 |
145 buddy = get_nick(jid) |
153 buddy = get_nick(jid) |
146 msg = 'sent you a message.' |
154 if jid in contact_custom_msg: |
|
155 msg = contact_custom_msg[jid] |
|
156 elif 'default' in contact_custom_msg: |
|
157 msg = contact_custom_msg['default'] |
|
158 else: |
|
159 msg = 'sent you a message.' |
147 |
160 |
148 if not is_blacklisted(jid): |
161 if not is_blacklisted(jid): |
149 textmsg = None |
162 textmsg = None |
150 |
163 |
151 if filename and os.path.exists(filename): |
164 if filename and os.path.exists(filename): |
219 last_conf_read = os.stat(CONFFILE).st_ctime |
232 last_conf_read = os.stat(CONFFILE).st_ctime |
220 except OSError: |
233 except OSError: |
221 sys.stderr.write("Cannot read config file!\n") |
234 sys.stderr.write("Cannot read config file!\n") |
222 sys.exit(3) |
235 sys.exit(3) |
223 |
236 |
|
237 NOTIFY_LOADED = False |
|
238 |
224 read_conf_from_file() |
239 read_conf_from_file() |
225 |
|
226 NOTIFY_LOADED = False |
|
227 |
240 |
228 # read stdin line by line |
241 # read stdin line by line |
229 while 1: |
242 while 1: |
230 try: |
243 try: |
231 line = sys.stdin.readline() |
244 line = sys.stdin.readline() |