Sat, 04 Oct 2014 15:06:38 +0300
- fixed: pulling commits from local zan-stable to zan-dev didn't work properly
0 | 1 | #!/usr/bin/env python |
2 | ''' | |
25
9fa1df6113c4
- changed the copyright line to use my proper legal name instead of my common calling name
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
3 | Copyright 2014 Teemu Piippo |
0 | 4 | All rights reserved. |
5 | ||
6 | Redistribution and use in source and binary forms, with or without | |
7 | modification, are permitted provided that the following conditions | |
8 | are met: | |
9 | ||
10 | 1. Redistributions of source code must retain the above copyright | |
11 | notice, this list of conditions and the following disclaimer. | |
12 | 2. Redistributions in binary form must reproduce the above copyright | |
13 | notice, this list of conditions and the following disclaimer in the | |
14 | documentation and/or other materials provided with the distribution. | |
15 | 3. The name of the author may not be used to endorse or promote products | |
16 | derived from this software without specific prior written permission. | |
17 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
19 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
21 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
23 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
27 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ''' | |
29 | ||
30 | import asyncore | |
31 | import socket | |
32 | import time | |
33 | import sys | |
34 | import traceback | |
35 | import re | |
36 | import json | |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
37 | import urllib |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
38 | import urllib2 |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
39 | import hgapi |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
40 | import os |
15
e7999383db5a
- don't crash if utf parsing yields an UnicodeDecodeError
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
41 | import suds |
23
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
42 | import math |
0 | 43 | |
44 | try: | |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
45 | uid = os.geteuid() |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
46 | except: |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
47 | uid = -1 |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
48 | |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
49 | if uid == 0 and raw_input ('Do you seriously want to run cobalt as root? [y/N] ') != 'y': |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
50 | quit() |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
51 | |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
52 | print 'Loading configuration...' |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
53 | try: |
0 | 54 | with open ('cobalt.json', 'r') as fp: |
55 | g_config = json.loads (fp.read()) | |
56 | except IOError as e: | |
57 | print 'couldn\'t open cobalt.json: %s' % e | |
58 | quit() | |
59 | ||
60 | g_admins = g_config['admins'] | |
61 | g_mynick = g_config['nickname'] | |
62 | ||
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
63 | g_idgamesSearchURL = 'http://www.doomworld.com/idgames/api/api.php?action=search&query=%s&type=title&sort=date&out=json' |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
64 | g_BotActive = False |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
65 | |
0 | 66 | # |
67 | # SOAP stuff | |
68 | # | |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
69 | suds_active = False |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
70 | |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
71 | try: |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
72 | print 'Initializing MantisBT connection...' |
15
e7999383db5a
- don't crash if utf parsing yields an UnicodeDecodeError
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
73 | suds_import = suds.xsd.doctor.Import ('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') |
e7999383db5a
- don't crash if utf parsing yields an UnicodeDecodeError
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
74 | suds_client = suds.client.Client ('https://zandronum.com/tracker/api/soap/mantisconnect.php?wsdl', plugins=[suds.xsd.doctor.ImportDoctor (suds_import)]) |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
75 | suds_active = True |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
76 | except Exception as e: |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
77 | print 'Failed to establish MantisBT connection: ' + `e` |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
78 | pass |
0 | 79 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
80 | btannounce_active = False |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
81 | btannounce_timeout = 0 |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
82 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
83 | def save_config(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
84 | with open ('cobalt.json', 'w') as fp: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
85 | json.dump (g_config, fp, sort_keys = True, indent = 4) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
86 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
87 | def cfg (key, default): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
88 | if not hasattr (g_config, key): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
89 | g_config[key] = default |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
90 | save_config() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
91 | return default |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
92 | return g_config[key] |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
93 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
94 | def bt_updatechecktimeout(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
95 | global btannounce_timeout |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
96 | btannounce_timeout = time.time() + (cfg ('btlatest_checkinterval', 5) * 60) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
97 | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
98 | def bool_from_string (value): |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
99 | if value != 'true' and value != 'false': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
100 | raise logical_exception ('expected true or false for value') |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
101 | return True if value == 'true' else False |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
102 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
103 | if suds_active: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
104 | try: |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
105 | sys.stdout.write ('Retrieving latest tracker ticket... ') |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
106 | btannounce_id = suds_client.service.mc_issue_get_biggest_id (g_config['trackeruser'], g_config['trackerpassword'], 0) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
107 | btannounce_active = True |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
108 | bt_updatechecktimeout() |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
109 | print btannounce_id |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
110 | except Exception as e: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
111 | pass |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
112 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
113 | def bt_getissue(ticket): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
114 | global suds_client |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
115 | global g_config |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
116 | return suds_client.service.mc_issue_get (g_config['trackeruser'], g_config['trackerpassword'], ticket) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
117 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
118 | def bt_checklatest(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
119 | global btannounce_timeout |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
120 | global btannounce_id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
121 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
122 | if time.time() >= btannounce_timeout: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
123 | bt_updatechecktimeout() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
124 | newid = btannounce_id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
125 | try: |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
126 | newid = suds_client.service.mc_issue_get_biggest_id (g_config['trackeruser'], g_config['trackerpassword'], 0) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
127 | except Exception as e: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
128 | pass |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
129 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
130 | while newid > btannounce_id: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
131 | try: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
132 | btannounce_id += 1 |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
133 | data = bt_getissue (btannounce_id) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
134 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
135 | for client in g_clients: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
136 | client.announce_ticket (data) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
137 | except Exception as e: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
138 | pass |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
139 | |
0 | 140 | # |
141 | # irc_client flags | |
142 | # | |
143 | CLIF_CONNECTED = (1 << 1) | |
144 | ||
145 | # | |
146 | # List of all clients | |
147 | # | |
148 | g_clients = [] | |
149 | ||
150 | class channel (object): | |
151 | name = "" | |
152 | password = "" | |
153 | ||
154 | def __init__ (self, name): | |
155 | self.name = name | |
156 | ||
157 | # | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
158 | # Prints a line to log channel(s) |
0 | 159 | # |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
160 | def chanlog (line): |
0 | 161 | for client in g_clients: |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
162 | if not client.flags & CLIF_CONNECTED: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
163 | continue |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
164 | |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
165 | for channel in client.channels: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
166 | if channel['logchannel']: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
167 | client.write ("PRIVMSG %s :%s" % (channel['name'], line)) |
0 | 168 | |
169 | # | |
170 | # Exception handling | |
171 | # | |
172 | def handle_exception(excType, excValue, trace): | |
173 | excepterm (traceback.format_exception(excType, excValue, trace)) | |
174 | ||
175 | def excepterm(data): | |
176 | for segment in data: | |
177 | for line in segment.splitlines(): | |
178 | print line | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
179 | chanlog (line) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
180 | |
0 | 181 | for client in g_clients: |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
182 | if len(data) > 0: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
183 | client.exceptdie() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
184 | else: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
185 | client.quit_irc() |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
186 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
187 | if g_BotActive: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
188 | restart_self() |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
189 | else: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
190 | quit() |
0 | 191 | |
192 | sys.excepthook = handle_exception | |
193 | ||
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
194 | def check_admin (sender, ident, host, command): |
16
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
195 | if not "%s@%s" % (ident, host) in g_admins: |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
196 | raise logical_exception (".%s requires admin access" % command) |
0 | 197 | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
198 | class logical_exception (Exception): |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
199 | def __init__ (self, value): |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
200 | self.value = value |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
201 | def __str__ (self): |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
202 | return self.value |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
203 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
204 | # from http://www.daniweb.com/software-development/python/code/260268/restart-your-python-program |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
205 | def restart_self(): |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
206 | python = sys.executable |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
207 | os.execl (python, python, * sys.argv) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
208 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
209 | ' Retrieves hg incoming from zandronum repository ' |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
210 | def get_incoming_data (zanrepo, rev, template): |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
211 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
212 | if rev != '': |
33 | 213 | return zanrepo.hg_command ('incoming', '--quiet', '-r', rev, '--template', template) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
214 | else: |
33 | 215 | return zanrepo.hg_command ('incoming', '--quiet', '--template', template) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
216 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
217 | except: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
218 | pass |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
219 | return "" |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
220 | #enddef |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
221 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
222 | ' Check if a repository exists ' |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
223 | def check_repo_exists (repo_name): |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
224 | print 'Checking that %s exists...' % repo_name |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
225 | repo_url = 'https://bitbucket.org/Torr_Samaho/' + repo_name |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
226 | zanrepo = hgapi.Repo (repo_name) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
227 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
228 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
229 | zanrepo.hg_command ('id', '.') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
230 | except hgapi.hgapi.HgException: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
231 | # If the repo does not exist, clone it. After cloning, there obviously |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
232 | # are no more updates, so we'll be done. |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
233 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
234 | print 'Cloning %s...' % repo_name |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
235 | zanrepo.hg_clone (repo_url, repo_name) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
236 | print 'Cloning done. No update checking needed.' |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
237 | except Exception as e: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
238 | print 'Unable to clone %s from %s: %s' % (repo_name, repo_url, str (`e`)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
239 | quit(1) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
240 | #tried |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
241 | #enddef |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
242 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
243 | check_repo_exists ('zandronum') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
244 | check_repo_exists ('zandronum-stable') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
245 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
246 | repocheck_timeout = {'zandronum':(time.time()) + 15, 'zandronum-stable':(time.time() + 15)} |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
247 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
248 | ' Retrieves and processes commits for zandronum repositories ' |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
249 | ' Ensure both repositories are OK before using this! ' |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
250 | def process_zan_repo_updates (repo_name): |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
251 | global repocheck_timeout |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
252 | global suds_client |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
253 | global g_config |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
254 | global g_clients |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
255 | |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
256 | usestable = repo_name == 'zandronum-stable' |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
257 | repo_url = 'https://bitbucket.org/Torr_Samaho/' + repo_name |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
258 | num_commits = 0 |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
259 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
260 | if time.time() < repocheck_timeout[repo_name]: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
261 | return |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
262 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
263 | repocheck_timeout[repo_name] = time.time() + (cfg ('hg_checkinterval', 15) * 60) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
264 | zanrepo = hgapi.Repo (repo_name) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
265 | data = get_incoming_data (zanrepo, '', '{node|short} {desc}\n') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
266 | commits_to_pull = []; |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
267 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
268 | for line in data.split ('\n'): |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
269 | if line == '': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
270 | continue |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
271 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
272 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
273 | rex = re.compile (r'^([^ ]+) (.+)$') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
274 | match = rex.match (line) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
275 | failed = False |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
276 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
277 | if not match: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
278 | chanlog ('malformed hg data: %s' % line) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
279 | continue |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
280 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
281 | |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
282 | commit_node = match.group (1) |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
283 | commit_message = match.group (2) |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
284 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
285 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
286 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
287 | rex = re.compile (r'^.*(fixes|resolves|addresses) ([0-9]+).*$') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
288 | match = rex.match (commit_message) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
289 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
290 | if not match: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
291 | continue # no "fixes" message in the commit |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
292 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
293 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
294 | ticket_id = int (match.group (2)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
295 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
296 | # Acquire additional data |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
297 | moredata = get_incoming_data (zanrepo, commit_node, |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
298 | '{author|nonempty}\n{date(date, \'%A %d %B %Y %T\')}\n{diffstat|nonempty}').split('\n') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
299 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
300 | if len (moredata) != 3: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
301 | chanlog ('commit %s: malformed hg data' % commit_node) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
302 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
303 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
304 | commit_author = moredata[0] |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
305 | commit_date = moredata[1] |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
306 | commit_diffstat = moredata[2] |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
307 | commit_email = "" |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
308 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
309 | ticket_data = suds_client.service.mc_issue_get (g_config['trackeruser'], g_config['trackerpassword'], ticket_id) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
310 | if not ticket_data: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
311 | chanlog ("error: commit %s: ticket %s not found" % (commit_node, ticket_id)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
312 | continue |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
313 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
314 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
315 | # Remove the email address from the author if possible |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
316 | rex = re.compile (r'^(.+) <([^>]+)>$.*') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
317 | match = rex.match (commit_author) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
318 | if match: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
319 | commit_author = match.group (1) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
320 | commit_email = match.group (2) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
321 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
322 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
323 | rex = re.compile (r'([0-9]+): \+([0-9]+)/-([0-9]+)') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
324 | match = rex.match (commit_diffstat) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
325 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
326 | if match: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
327 | modded = int (match.group (1)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
328 | added = int (match.group (2)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
329 | deleted = int (match.group (3)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
330 | commit_diffstat = "%s file%s modified, %s line%s added, %s line%s removed" % \ |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
331 | (modded if modded != 0 else 'no', |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
332 | 's' if modded != 1 else '', |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
333 | added if added != 0 else 'no', |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
334 | 's' if added != 1 else '', |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
335 | deleted if deleted != 0 else 'no', |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
336 | 's' if deleted != 1 else '') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
337 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
338 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
339 | files_added = filter (None, get_incoming_data (zanrepo, commit_node, '{file_adds}').split ('\n')) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
340 | files_removed = filter (None, get_incoming_data (zanrepo, commit_node, '{file_dels}').split ('\n')) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
341 | files_changed = filter (None, get_incoming_data (zanrepo, commit_node, '{file_mods}').split ('\n')) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
342 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
343 | # Compare the email addresses against known developer usernames |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
344 | commit_trackeruser = '' |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
345 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
346 | for developer, emails in g_config['developer_emails'].iteritems(): |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
347 | for email in emails: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
348 | if commit_email == email: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
349 | commit_trackeruser = developer |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
350 | break; |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
351 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
352 | else: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
353 | continue |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
354 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
355 | break |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
356 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
357 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
358 | if commit_trackeruser != '': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
359 | commit_author += ' [%s]' % commit_trackeruser |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
360 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
361 | |
37
3399d716b3ae
- fixed: the [url] tags in BT messages had unnecessary quotes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
362 | message = 'Issue addressed by commit %s: [b][url=%s/commits/%s]%s[/url][/b]' \ |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
363 | % (commit_node, repo_url, commit_node, commit_message) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
364 | message += "\nCommitted by %s on %s\n\n%s" \ |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
365 | % (commit_author, commit_date, commit_diffstat) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
366 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
367 | if len (files_added) > 0: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
368 | message += "\nFiles added: %s" % ', '.join (files_added) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
369 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
370 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
371 | if len (files_removed) > 0: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
372 | message += "\nFiles removed: %s" % ', '.join (files_removed) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
373 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
374 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
375 | if len (files_changed) > 0: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
376 | message += "\nFiles changed: %s" % ', '.join (files_changed) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
377 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
378 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
379 | need_update = False |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
380 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
381 | # If not already set, set handler |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
382 | if not 'handler' in ticket_data: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
383 | ticket_data['handler'] = {'name': commit_trackeruser} |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
384 | need_update = True |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
385 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
386 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
387 | # Find out the status level of the ticket |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
388 | needs_testing_level = 70 |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
389 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
390 | if ticket_data['status']['id'] < needs_testing_level: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
391 | ticket_data.status['id'] = needs_testing_level |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
392 | need_update = True |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
393 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
394 | |
35
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
395 | # Set target version if not set |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
396 | if not 'target_version' in ticket_data: |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
397 | ticket_data['target_version'] = '1.3' if repo_name == 'zandronum-stable' else '2.0' |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
398 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
399 | elif (ticket_data['target_version'] == '2.0' or ticket_data['target_version'] == '2.0-beta') \ |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
400 | and repo_name == 'zandronum-stable': |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
401 | # Target version was 2.0 but this was just committed to zandronum-stable, adjust |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
402 | ticket_data['target_version'] = '1.3' |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
403 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
404 | elif ticket_data['target_version'] == '2.0-beta': |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
405 | # Fix target version from 2.0-beta to 2.0 |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
406 | ticket_data['target_version'] = '2.0' |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
407 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
408 | #fi |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
409 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
410 | # Announce on IRC |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
411 | for irc_client in g_clients: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
412 | for channel in irc_client.cfg['channels']: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
413 | if 'btannounce' in channel and channel['btannounce'] == True: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
414 | irc_client.privmsg (channel['name'], |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
415 | "%s: commit %s fixes issue %d: %s" |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
416 | % (repo_name, commit_node, ticket_id, commit_message)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
417 | irc_client.privmsg (channel['name'], |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
418 | "Read all about it here: " + irc_client.get_ticket_url (ticket_id)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
419 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
420 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
421 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
422 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
423 | if need_update: |
36
543d7a5e3b8b
- when updating BT tickets, the note data must be cleared in order to not update all the tickets in the ticket. WTF is MantisBT smoking?
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
424 | # We need to remove the note data, otherwise the ticket notes |
543d7a5e3b8b
- when updating BT tickets, the note data must be cleared in order to not update all the tickets in the ticket. WTF is MantisBT smoking?
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
425 | # will get unnecessary updates. WTF, MantisBT? |
543d7a5e3b8b
- when updating BT tickets, the note data must be cleared in order to not update all the tickets in the ticket. WTF is MantisBT smoking?
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
426 | ticket_data.notes = [] |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
427 | suds_client.service.mc_issue_update (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, ticket_data) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
428 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
429 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
430 | suds_client.service.mc_issue_note_add (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, { 'text': message }) |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
431 | num_commits += 1 |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
432 | except Exception as e: |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
433 | chanlog ('Error while processing %s: %s' % (commit_node, `e`)) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
434 | failed = True |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
435 | #tried |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
436 | |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
437 | commits_to_pull.append (commit_node) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
438 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
439 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
440 | if len (commits_to_pull) > 0: |
33 | 441 | pull_args = ['pull'] |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
442 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
443 | for commit in commits_to_pull: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
444 | pull_args.append ('-r'); |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
445 | pull_args.append (commit); |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
446 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
447 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
448 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
449 | zanrepo.hg_command (*pull_args) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
450 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
451 | # Also pull these commits to the zandronum main repository |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
452 | if usestable: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
453 | devrepo = hgapi.Repo ('zandronum') |
38
71046c4430d1
- fixed: pulling commits from local zan-stable to zan-dev didn't work properly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
37
diff
changeset
|
454 | pull_args.insert (1, '../zandronum-stable') |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
455 | devrepo.hg_command (*pull_args) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
456 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
457 | except Exception as e: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
458 | chanlog ('Warning: unable to pull: %s' % `e`) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
459 | #tried |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
460 | #fi |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
461 | |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
462 | return num_commits > 0 |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
463 | #enddef |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
464 | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
465 | # |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
466 | # Main IRC client class |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
467 | # |
0 | 468 | class irc_client (asyncore.dispatcher): |
469 | def __init__ (self, cfg, flags): | |
470 | self.name = cfg['name'] | |
471 | self.host = cfg['address'] | |
472 | self.port = cfg['port'] | |
473 | self.password = cfg['password'] if 'password' in cfg else '' | |
474 | self.channels = cfg['channels'] | |
475 | self.flags = flags | |
476 | self.send_buffer = list() | |
477 | self.umode = cfg['umode'] if 'umode' in cfg else '' | |
478 | self.cfg = cfg | |
479 | self.mynick = '' | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
480 | self.verbose = g_config['verbose'] if 'verbose' in g_config else False |
11
90851b22ab88
- gddmnt, python. you and your type system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
481 | self.commandprefix = g_config['commandprefix'][0] if 'commandprefix' in g_config else '.' |
8
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
482 | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
483 | for channel in self.channels: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
484 | if not 'logchannel' in channel: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
485 | channel['logchannel'] = False |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
486 | channel['namesdone'] = True |
27
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
487 | #channel['haslinkbot'] = False |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
488 | |
8
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
489 | if not 'conflictsuffix' in self.cfg: |
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
490 | self.cfg['conflictsuffix'] = '`' |
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
491 | |
7
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
492 | self.desired_name = self.cfg['nickname'] if 'nickname' in self.cfg else g_config['nickname'] |
0 | 493 | g_clients.append (self) |
494 | asyncore.dispatcher.__init__ (self) | |
495 | self.create_socket (socket.AF_INET, socket.SOCK_STREAM) | |
496 | self.connect ((self.host, self.port)) | |
497 | ||
7
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
498 | def register_to_irc (self): |
0 | 499 | ident = self.cfg['ident'] if 'ident' in self.cfg else g_config['ident'] |
500 | gecos = self.cfg['gecos'] if 'gecos' in self.cfg else g_config['gecos'] | |
501 | if 'password' in self.cfg: | |
502 | self.write ("PASS %s" % self.cfg['password']) | |
503 | self.write ("USER %s * * :%s" % (ident, gecos)) | |
7
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
504 | self.write ("NICK %s" % self.mynick) |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
505 | |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
506 | def handle_connect (self): |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
507 | self.mynick = self.desired_name |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
508 | print "Connected to [%s] %s:%d" % (self.name, self.host, self.port) |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
509 | self.register_to_irc() |
0 | 510 | |
17
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
511 | def write (self, utfdata): |
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
512 | try: |
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
513 | self.send_buffer.append ("%s" % utfdata.decode("utf-8","ignore").encode("ascii","ignore")) |
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
514 | except UnicodeEncodeError: |
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
515 | pass |
0 | 516 | |
517 | def handle_close (self): | |
518 | print "Connection to [%s] %s:%d terminated." % (self.name, self.host, self.port) | |
519 | self.close() | |
520 | ||
521 | def handle_write (self): | |
522 | self.send_all_now() | |
523 | ||
524 | def readable (self): | |
525 | return True | |
526 | ||
527 | def writable (self): | |
528 | return len (self.send_buffer) > 0 | |
529 | ||
530 | def send_all_now (self): | |
531 | for line in self.send_buffer: | |
9
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
532 | if self.verbose: |
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
533 | print "[%s] <- %s" % (self.name, line) |
0 | 534 | self.send ("%s\n" % line) |
535 | self.send_buffer = [] | |
536 | ||
537 | def handle_read (self): | |
538 | lines = self.recv (4096).splitlines() | |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
539 | for utfline in lines: |
16
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
540 | try: |
17
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
541 | line = utfline.decode("utf-8","ignore").encode("ascii","ignore") |
16
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
542 | except UnicodeDecodeError: |
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
543 | continue |
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
544 | |
9
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
545 | if self.verbose: |
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
546 | print "[%s] -> %s" % (self.name, line) |
0 | 547 | |
548 | if line.startswith ("PING :"): | |
549 | self.write ("PONG :%s" % line[6:]) | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
550 | else: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
551 | words = line.split(" ") |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
552 | if len(words) >= 2: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
553 | if words[1] == "001": |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
554 | self.flags |= CLIF_CONNECTED |
0 | 555 | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
556 | for channel in self.cfg['channels']: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
557 | self.write ("JOIN %s %s" % (channel['name'], channel['password'] if 'password' in channel else '')) |
0 | 558 | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
559 | if 'umode' in self.cfg: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
560 | self.write ('MODE %s %s' % (self.mynick, self.cfg['umode'])) |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
561 | elif words[1] == "PRIVMSG": |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
562 | self.handle_privmsg (line) |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
563 | elif words[1] == 'JOIN': |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
564 | rex = re.compile (r'^:([^!]+)!([^@]+)@([^ ]+) JOIN :#(.+)') |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
565 | match = rex.match (line) |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
566 | |
27
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
567 | #if match and match.group(1).toLower() == 'linkbot': |
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
568 | #channel_by_name (match.group(4))['haslinkbot'] = True |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
569 | elif words[1] == 'QUIT': |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
570 | rex = re.compile (r'^:([^!]+)!([^@]+)@([^ ]+) QUIT') |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
571 | match = rex.match (line) |
0 | 572 | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
573 | # Try reclaim our nickname if possible |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
574 | if match and match.group(1) == self.desired_name: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
575 | self.mynick = self.desired_name |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
576 | self.write ("NICK %s" % self.mynick) |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
577 | |
27
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
578 | #if match and match.group(1).toLower() == 'linkbot': |
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
579 | #for channel in self.channels: |
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
580 | #channels['haslinkbot'] = False |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
581 | elif words[1] == "433": |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
582 | #:irc.localhost 433 * cobalt :Nickname is already in use. |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
583 | self.mynick = '%s%s' % (self.mynick, self.cfg['conflictsuffix']) |
7
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
584 | self.write ("NICK %s" % self.mynick) |
0 | 585 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
586 | # Check for new issues on the bugtracker |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
587 | bt_checklatest() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
588 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
589 | # Check for new commits in the repositories |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
590 | for n in ['zandronum-stable', 'zandronum']: |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
591 | process_zan_repo_updates (n) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
592 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
593 | def channel_by_name (self, name): |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
594 | for channel in self.channels: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
595 | if channel['name'].upper() == args[0].upper(): |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
596 | return channel |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
597 | else: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
598 | raise logical_exception ('unknown channel ' + args[0]) |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
599 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
600 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
601 | # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
602 | # Handle a PRIVMSG line from the IRC server |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
603 | # |
0 | 604 | def handle_privmsg (self, line): |
605 | rex = re.compile (r'^:([^!]+)!([^@]+)@([^ ]+) PRIVMSG ([^ ]+) :(.+)$') | |
606 | match = rex.match (line) | |
607 | if match: | |
608 | sender = match.group (1) | |
609 | user = match.group (2) | |
610 | host = match.group (3) | |
611 | channel = match.group (4) | |
612 | message = match.group (5) | |
613 | replyto = channel if channel != g_mynick else sender | |
614 | ||
615 | # Check for tracker url in the message | |
616 | http_regex = re.compile (r'.*http(s?)://%s/view\.php\?id=([0-9]+).*' % g_config['trackerurl']) | |
617 | http_match = http_regex.match (line) | |
618 | ||
619 | # Check for command. | |
10
1b726db7b0ec
- respect the commandprefix option
Santeri Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
620 | if len(message) >= 2 and message[0] == self.commandprefix and message[1] != self.commandprefix: |
0 | 621 | stuff = message[1:].split(' ') |
622 | command = stuff[0] | |
623 | args = stuff[1:] | |
624 | try: | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
625 | self.handle_command (sender, user, host, replyto, command, args) |
21
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
626 | except logical_exception as e: |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
627 | for line in e.value.split ('\n'): |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
628 | if len(line) > 0: |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
629 | self.privmsg (replyto, "error: %s" % line) |
0 | 630 | elif http_match: |
631 | self.get_ticket_data (replyto, http_match.group (2), False) | |
632 | else: | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
633 | chanlog ("Recieved bad PRIVMSG: %s" % line) |
0 | 634 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
635 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
636 | # |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
637 | # Get the URL for a specified ticket |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
638 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
639 | def get_ticket_url (self, ticket): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
640 | return 'https://%s/view.php?id=%s' % (g_config['trackerurl'], ticket) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
641 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
642 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
643 | # |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
644 | # Retrieve a ticket from mantisbt |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
645 | # |
0 | 646 | def get_ticket_data (self, replyto, ticket, withlink): |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
647 | if suds_active == False: |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
648 | return |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
649 | |
0 | 650 | data = {} |
651 | try: | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
652 | data = bt_getissue (ticket) |
0 | 653 | except Exception, e: |
654 | self.privmsg (replyto, "Failed to get info for issue %s: %s" % (ticket, `e`)) | |
655 | ||
656 | if data: | |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
657 | if data['view_state']['name'] == 'private': |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
658 | allowprivate = False |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
659 | |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
660 | for channel in self.channels: |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
661 | if channel['name'] == replyto and 'btprivate' in channel and channel['btprivate'] == True: |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
662 | allowprivate = True |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
663 | break |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
664 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
665 | #done |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
666 | |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
667 | if not allowprivate: |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
668 | self.privmsg (replyto, 'Error: ticket %s is private' % ticket) |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
669 | return |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
670 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
671 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
672 | |
0 | 673 | self.privmsg (replyto, "Issue %s: %s: Reporter: %s, assigned to: %s, status: %s (%s)" % \ |
674 | (ticket, \ | |
675 | data.summary, \ | |
4
bd9508f8a10f
- don't crash if ticket data doesn't have a reporter name (can happen if the reporter is banned)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
676 | data.reporter.name if hasattr (data.reporter, 'name') else "<unknown>", \ |
0 | 677 | data.handler.name if hasattr (data, 'handler') else "nobody", \ |
678 | data.status.name, \ | |
679 | data.resolution.name)) | |
680 | ||
681 | if withlink: | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
682 | self.privmsg (replyto, "Read all about it here: " + self.get_ticket_url (ticket)) |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
683 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
684 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
685 | #enddef |
0 | 686 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
687 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
688 | # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
689 | # Process an IRC command |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
690 | # |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
691 | def handle_command (self, sender, ident, host, replyto, command, args): |
0 | 692 | if command == "raw": |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
693 | check_admin (sender, ident, host, command) |
0 | 694 | self.write (" ".join (args)) |
695 | elif command == "msg": | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
696 | check_admin (sender, ident, host, command) |
0 | 697 | if len(args) < 2: |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
698 | raise logical_exception ("usage: .%s <target> <message...>" % command) |
0 | 699 | self.privmsg (args[0], " ".join (args[1:])) |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
700 | elif command == 'ticket': |
0 | 701 | if len(args) != 1: |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
702 | raise logical_exception ("usage: .%s <ticket>" % command) |
0 | 703 | self.get_ticket_data (replyto, args[0], True) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
704 | elif command == 'testannounce': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
705 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
706 | if len(args) != 1: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
707 | raise logical_exception ("usage: .%s <ticket>" % command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
708 | self.announce_ticket (bt_getissue (args[0])) |
21
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
709 | elif command == 'multierror': |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
710 | raise logical_exception ('a\nb\nc\n') |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
711 | elif command == 'idgames': |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
712 | try: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
713 | if len(args) < 1: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
714 | raise logical_exception ('usage: .%s <keywords>' % command) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
715 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
716 | url = g_idgamesSearchURL % urllib.quote (" ".join (args[0:])) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
717 | response = urllib2.urlopen (url).read() |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
718 | data = json.loads (response) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
719 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
720 | if 'content' in data and 'file' in data['content']: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
721 | if type (data['content']['file']) is list: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
722 | files = data['content']['file'] |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
723 | else: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
724 | files = [data['content']['file']] |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
725 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
726 | i = 0 |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
727 | for filedata in files: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
728 | if i >= 5: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
729 | break |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
730 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
731 | self.privmsg (replyto, '- %s: \'%s\' by \'%s\', rating: %s: %s' % \ |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
732 | (filedata['filename'], filedata['title'], filedata['author'], filedata['rating'], filedata['url'])) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
733 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
734 | i += 1 |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
735 | self.privmsg (replyto, "(%d / %d results posted)" % (i, len(files))) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
736 | elif 'warning' in data and 'message' in data['warning']: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
737 | raise logical_exception (data['warning']['message']) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
738 | elif 'error' in data and 'message' in data['error']: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
739 | raise logical_exception (data['error']['message']) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
740 | else: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
741 | raise logical_exception ("Incomplete JSON response from doomworld.com/idgames") |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
742 | except logical_exception as e: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
743 | raise e |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
744 | except Exception as e: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
745 | raise logical_exception ('Search failed: %s' % `e`) |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
746 | elif command == 'restart': |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
747 | check_admin (sender, ident, host, command) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
748 | excepterm('') |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
749 | elif command == 'update': |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
750 | check_admin (sender, ident, host, command) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
751 | |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
752 | try: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
753 | repo = hgapi.Repo ('.') |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
754 | r1 = repo.hg_id() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
755 | repo.hg_pull() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
756 | repo.hg_update('tip', True) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
757 | r2 = repo.hg_id() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
758 | if r1 != r2: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
759 | self.privmsg (replyto, 'Updated to %s, restarting...' % r2) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
760 | excepterm('') |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
761 | else: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
762 | self.privmsg (replyto, 'Up to date at %s.' % r2) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
763 | except hgapi.HgException as e: |
21
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
764 | raise logical_exception ('Update failed: %s' % str (e)) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
765 | elif command == 'addchan': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
766 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
767 | if len(args) != 1: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
768 | raise logical_exception ("usage: .%s <channel>" % command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
769 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
770 | for channel in self.channels: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
771 | if channel['name'].upper() == args[0].upper(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
772 | raise logical_exception ('I already know of %s!' % args[0]) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
773 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
774 | chan = {} |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
775 | chan['name'] = args[0] |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
776 | chan['logchannel'] = False |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
777 | self.channels.append (chan) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
778 | self.write ('JOIN ' + chan['name']) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
779 | save_config() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
780 | elif command == 'delchan': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
781 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
782 | if len(args) != 1: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
783 | raise logical_exception ("usage: .%s <channel>" % command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
784 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
785 | for channel in self.channels: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
786 | if channel['name'].upper() == args[0].upper(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
787 | break; |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
788 | else: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
789 | raise logical_exception ('unknown channel ' + args[0]) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
790 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
791 | self.channels.remove (channel) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
792 | self.write ('PART ' + args[0]) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
793 | save_config() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
794 | elif command == 'chanattr': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
795 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
796 | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
797 | if len(args) < 1: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
798 | raise logical_exception ("usage: .%s <attribute> [value...]" % command) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
799 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
800 | for channel in self.channels: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
801 | if channel['name'] == replyto: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
802 | break |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
803 | else: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
804 | raise logical_exception ('I don\'t know of a channel named ' + replyto) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
805 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
806 | key = args[0] |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
807 | |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
808 | if len(args) < 2: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
809 | try: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
810 | self.privmsg (replyto, '%s = %s' % (key, channel[key])) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
811 | except KeyError: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
812 | self.privmsg (replyto, 'attribute %s is not set' % key) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
813 | else: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
814 | value = " ".join (args[1:]) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
815 | if key == 'name': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
816 | if replyto == channel['name']: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
817 | replyto = value |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
818 | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
819 | self.write ('PART ' + channel['name']) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
820 | channel['name'] = value |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
821 | self.write ('JOIN ' + channel['name'] + ' ' + (channel['password'] if hasattr (channel, 'password') else '')) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
822 | elif key == 'password': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
823 | channel['password'] = value |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
824 | elif key == 'btannounce': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
825 | channel['btannounce'] = bool_from_string (value) |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
826 | elif key == 'btprivate': |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
827 | channel['btprivate'] = bool_from_string (value) |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
828 | elif key == 'logchannel': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
829 | channel['logchannel'] = bool_from_string (value) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
830 | else: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
831 | raise logical_exception ('unknown key ' + key) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
832 | |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
833 | self.privmsg (replyto, '%s is now %s' % (key, channel[key])) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
834 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
835 | save_config() |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
836 | elif command == 'devemail': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
837 | check_admin (sender, ident, host, command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
838 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
839 | if len(args) < 2: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
840 | raise logical_exception ("usage: .%s <user> <email>" % command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
841 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
842 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
843 | if not 'developer_emails' in g_config: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
844 | g_config['developer_emails'] = {} |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
845 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
846 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
847 | user = ' '.join (args[0:-1]) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
848 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
849 | if args[0] in g_config['developer_emails']: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
850 | g_config['developer_emails'][user].append (args[-1]) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
851 | else: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
852 | g_config['developer_emails'][user] = [args[-1]] |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
853 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
854 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
855 | self.privmsg (replyto, 'Developer emails for %s are now %s' % |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
856 | (user, ', '.join (g_config['developer_emails'][user]))) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
857 | save_config() |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
858 | elif command == 'deldevemail': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
859 | check_admin (sender, ident, host, command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
860 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
861 | if len(args) < 2: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
862 | raise logical_exception ("usage: .%s <user> <email>" % command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
863 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
864 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
865 | if not 'developer_emails' in g_config: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
866 | g_config['developer_emails'] = {} |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
867 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
868 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
869 | user = ' '.join (args[0:-1]) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
870 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
871 | if user in g_config['developer_emails']: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
872 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
873 | g_config['developer_emails'][user].remove (args[-1]) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
874 | except: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
875 | pass |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
876 | #tried |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
877 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
878 | if len (g_config['developer_emails'][user]) == 0: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
879 | g_config['developer_emails'].pop (user) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
880 | self.privmsg (replyto, 'No more developer emails for %s' % user) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
881 | else: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
882 | self.privmsg (replyto, 'Developer emails for %s are now %s' % |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
883 | (user, ', '.join (g_config['developer_emails'][user]))) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
884 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
885 | save_config() |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
886 | else: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
887 | self.privmsg (replyto, 'There is no developer \'%s\'' % user) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
888 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
889 | elif command == 'listdevemails': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
890 | check_admin (sender, ident, host, command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
891 | |
30
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
892 | if 'developer_emails' in g_config: |
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
893 | for dev, emails in g_config['developer_emails'].iteritems(): |
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
894 | self.privmsg (replyto, 'Emails for %s: %s' % (dev, ', '.join (emails))) |
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
895 | #done |
31
4e3259daa425
- GOD. DAMNIT. PYTHON.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
896 | else: |
30
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
897 | self.privmsg (replyto, 'No dev emails.') |
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
898 | #fi |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
899 | elif command == 'checkhg': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
900 | check_admin (sender, ident, host, command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
901 | global repocheck_timeout |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
902 | repocheck_timeout = {'zandronum':0, 'zandronum-stable':0} |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
903 | |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
904 | for n in ['zandronum-stable', 'zandronum']: |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
905 | numcommits = process_zan_repo_updates (n) |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
906 | |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
907 | if numcommits == 0: |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
908 | self.privmsg (replyto, 'No new commits in ' + n) |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
909 | #fi |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
910 | #done |
6 | 911 | elif command == 'die': |
912 | check_admin (sender, ident, host, command) | |
913 | quit() | |
23
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
914 | elif command == 'convert': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
915 | if len(args) != 3 or args[1] != 'as': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
916 | raise logical_exception ("usage: .%s <value> as <valuetype>" % command) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
917 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
918 | value = float (args[0]) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
919 | valuetype = args[2] |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
920 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
921 | if valuetype in ['radians', 'degrees']: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
922 | if valuetype == 'radians': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
923 | radvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
924 | degvalue = (value * 180.) / math.pi |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
925 | else: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
926 | radvalue = (value * math.pi) / 180. |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
927 | degvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
928 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
929 | self.privmsg (replyto, '%s radians, %s degrees (%s)' %(radvalue, degvalue, degvalue % 360.)) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
930 | elif valuetype in ['celsius', 'fahrenheit']: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
931 | if valuetype == 'celsius': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
932 | celvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
933 | fahrvalue = value * 1.8 + 32 |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
934 | else: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
935 | celvalue = (value - 32) / 1.8 |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
936 | fahrvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
937 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
938 | self.privmsg (replyto, '%s degrees celsius, %s degrees fahrenheit' %(celvalue, fahrvalue)) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
939 | else: |
24 | 940 | raise logical_exception ('unknown valuetype, expected one of: degrees, radians (angle conversion), ' + |
941 | 'celsius, fahrenheit (temperature conversion)') | |
28
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
942 | elif command == 'urban' or command == 'ud': |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
943 | try: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
944 | if len(args) < 1: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
945 | raise logical_exception ('usage: %s <word>' % command) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
946 | |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
947 | url = 'http://api.urbandictionary.com/v0/define?term=%s' % ('%20'.join (args)) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
948 | response = urllib2.urlopen (url).read() |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
949 | data = json.loads (response) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
950 | |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
951 | if 'list' in data and len(data['list']) > 0 and 'word' in data['list'][0] and 'definition' in data['list'][0]: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
952 | word = data['list'][0]['word'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
953 | definition = data['list'][0]['definition'].replace ('\r', ' ').replace ('\n', ' ').replace (' ', ' ') |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
954 | up = data['list'][0]['thumbs_up'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
955 | down = data['list'][0]['thumbs_down'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
956 | self.privmsg (replyto, "\002%s\002: %s\0033 %d\003 up,\0035 %d\003 down" % (word, definition, up, down)) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
957 | else: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
958 | self.privmsg (replyto, "couldn't find a definition of \002%s\002" % args[0]) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
959 | except logical_exception as e: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
960 | raise e |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
961 | except Exception as e: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
962 | raise logical_exception ('Urban dictionary lookup failed: %s' % `e`) |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
963 | # else: |
28
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
964 | # raiee logical_exception ("unknown command `.%s`" % command) |
0 | 965 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
966 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
967 | # Print a ticket announce to appropriate channels |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
968 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
969 | def announce_ticket (self, data): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
970 | idstring = "%d" % data.id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
971 | while len(idstring) < 7: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
972 | idstring = "0" + idstring |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
973 | |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
974 | isprivate = data['view_state']['name'] == 'private' |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
975 | reporter = data['reporter']['name'] if hasattr (data['reporter'], 'name') else '<nobody>' |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
976 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
977 | for channel in self.cfg['channels']: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
978 | if 'btannounce' in channel and channel['btannounce'] == True: |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
979 | if not isprivate or ('btprivate' in channel and channel['btprivate'] == True): |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
980 | self.write ("PRIVMSG %s :[%s] New issue %s, reported by %s: %s: %s" % \ |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
981 | (channel['name'], data['project']['name'], idstring, reporter, |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
982 | data['summary'], self.get_ticket_url (idstring))) |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
983 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
984 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
985 | #done |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
986 | |
0 | 987 | def handle_error(self): |
988 | excepterm (traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) | |
989 | ||
990 | def privmsg (self, channel, msg): | |
991 | self.write ("PRIVMSG %s :%s" % (channel, msg)) | |
992 | ||
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
993 | def close_connection (self, message): |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
994 | if self.flags & CLIF_CONNECTED: |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
995 | self.write ("QUIT :" + message) |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
996 | self.send_all_now() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
997 | self.close() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
998 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
999 | def quit_irc (self): |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1000 | self.close_connection ('Leaving') |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1001 | |
0 | 1002 | def exceptdie (self): |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1003 | self.close_connection ('Caught exception') |
0 | 1004 | |
1005 | def keyboardinterrupt (self): | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1006 | self.close_connection ('KeyboardInterrupt') |
0 | 1007 | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
1008 | # |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
1009 | # Main procedure: |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
1010 | # |
0 | 1011 | try: |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1012 | for aconn in g_config['autoconnect']: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1013 | for conndata in g_config['connections']: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1014 | if conndata['name'] == aconn: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1015 | irc_client (conndata, 0) |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1016 | break |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1017 | else: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1018 | raise logical_exception ("unknown autoconnect entry %s" % (aconn)) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
1019 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1020 | g_BotActive = True |
0 | 1021 | asyncore.loop() |
1022 | except KeyboardInterrupt: | |
1023 | for client in g_clients: | |
1024 | client.keyboardinterrupt() | |
1025 | quit() |