Merge lp:~sushkov/ubuntu-bots/irclogin-fixes into lp:~tsimpson/ubuntu-bots/tweak

Proposed by Stas Sușcov
Status: Rejected
Rejected by: Terence Simpson
Proposed branch: lp:~sushkov/ubuntu-bots/irclogin-fixes
Merge into: lp:~tsimpson/ubuntu-bots/tweak
Diff against target: 51 lines (+8/-8)
1 file modified
IRCLogin/lp.py (+8/-8)
To merge this branch: bzr merge lp:~sushkov/ubuntu-bots/irclogin-fixes
Reviewer Review Type Date Requested Status
Terence Simpson Disapprove
Review via email: mp+19718@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stas Sușcov (sushkov) wrote :

Fixed fetching of IRC nicknames. Didn't work cause of layout changes.

Still login won't work cause of FreeNode's IRCd upgraded servers. The new `/whois` reponse is not handled anymore by supybot. Stuff like `msg.tagged('identified')` is not recognized anymore.

Revision history for this message
Terence Simpson (tsimpson) wrote :

The HTML scraping is not maintained and will be removed once bug #488394 is fixed

review: Disapprove

Unmerged revisions

155. By Stas Sușcov

Now IRC nicknames should work with lp's latest layout

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'IRCLogin/lp.py'
2--- IRCLogin/lp.py 2009-10-12 18:26:35 +0000
3+++ IRCLogin/lp.py 2010-02-19 15:51:15 +0000
4@@ -38,26 +38,26 @@
5 '''getIRCNick(user, errors) -> list
6 Try to get the IRC nick(s) from the LP account "user".
7 If errors is True print any errors to stderr, defaults to True
8-'''
9+'''
10 # Get the HTML data from LP
11 try:
12 data = urllib2.urlopen('https://launchpad.net/~%s' % user).read()
13 except Exception, e:
14 if errors: print >> sys.stderr, "Could not get user info (%s)" % e
15 return
16- details = '<div class="portletContent portletBody">'
17+ details = '<div class="portlet" id="contact-details">'
18 # Try and find the "Contact details" section
19 sindex = data.find(details)
20 if sindex == -1:
21 if errors: print >> sys.stderr, "Could not get user info (No data)"
22 return
23- eindex = data.find('</div>', sindex) + 6
24+ eindex = data.find('<dt>OpenPGP', sindex) + 6
25 data = data[sindex:eindex]
26 data = [l.strip() for l in data.splitlines() if l.strip()]
27 # Look for IRC info
28 try:
29- sindex = data.index('<th>IRC:</th>')
30- eindex = data.index('</div>', sindex)
31+ sindex = data.index('<dt>IRC:')
32+ eindex = data.index('</dl>', sindex)
33 except:
34 if errors: print >> sys.stderr, "Could not get user info (No IRC nick(s) specified)"
35 return
36@@ -71,12 +71,12 @@
37 break # Try not to loop forever :)
38 try:
39 # When this fails, it raises an exception
40- s = data.index('<th>IRC:</th>')
41- e = data.index('</tr>') + 1
42+ s = data.index('<dd>')
43+ e = data.index('</dd>') + 1
44 if e <= s:
45 break
46 # Limit to freenode nicks
47- if 'freenode' in data[s:e] or 'ubuntu' in data[s:e]:
48+ if '<strong>irc.freenode.net</strong>' in data[s:e] or '<strong>irc.ubuntu.com</strong>' in data[s:e]:
49 ircnames.append(data[s:e])
50 del data[s:e]
51 except:

Subscribers

People subscribed via source and target branches