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
=== modified file 'IRCLogin/lp.py'
--- IRCLogin/lp.py 2009-10-12 18:26:35 +0000
+++ IRCLogin/lp.py 2010-02-19 15:51:15 +0000
@@ -38,26 +38,26 @@
38 '''getIRCNick(user, errors) -> list38 '''getIRCNick(user, errors) -> list
39Try to get the IRC nick(s) from the LP account "user".39Try to get the IRC nick(s) from the LP account "user".
40If errors is True print any errors to stderr, defaults to True40If errors is True print any errors to stderr, defaults to True
41'''41'''
42 # Get the HTML data from LP42 # Get the HTML data from LP
43 try:43 try:
44 data = urllib2.urlopen('https://launchpad.net/~%s' % user).read()44 data = urllib2.urlopen('https://launchpad.net/~%s' % user).read()
45 except Exception, e:45 except Exception, e:
46 if errors: print >> sys.stderr, "Could not get user info (%s)" % e46 if errors: print >> sys.stderr, "Could not get user info (%s)" % e
47 return47 return
48 details = '<div class="portletContent portletBody">'48 details = '<div class="portlet" id="contact-details">'
49 # Try and find the "Contact details" section49 # Try and find the "Contact details" section
50 sindex = data.find(details)50 sindex = data.find(details)
51 if sindex == -1:51 if sindex == -1:
52 if errors: print >> sys.stderr, "Could not get user info (No data)"52 if errors: print >> sys.stderr, "Could not get user info (No data)"
53 return53 return
54 eindex = data.find('</div>', sindex) + 654 eindex = data.find('<dt>OpenPGP', sindex) + 6
55 data = data[sindex:eindex]55 data = data[sindex:eindex]
56 data = [l.strip() for l in data.splitlines() if l.strip()]56 data = [l.strip() for l in data.splitlines() if l.strip()]
57 # Look for IRC info57 # Look for IRC info
58 try:58 try:
59 sindex = data.index('<th>IRC:</th>')59 sindex = data.index('<dt>IRC:')
60 eindex = data.index('</div>', sindex)60 eindex = data.index('</dl>', sindex)
61 except:61 except:
62 if errors: print >> sys.stderr, "Could not get user info (No IRC nick(s) specified)"62 if errors: print >> sys.stderr, "Could not get user info (No IRC nick(s) specified)"
63 return63 return
@@ -71,12 +71,12 @@
71 break # Try not to loop forever :)71 break # Try not to loop forever :)
72 try:72 try:
73 # When this fails, it raises an exception73 # When this fails, it raises an exception
74 s = data.index('<th>IRC:</th>')74 s = data.index('<dd>')
75 e = data.index('</tr>') + 175 e = data.index('</dd>') + 1
76 if e <= s:76 if e <= s:
77 break77 break
78 # Limit to freenode nicks78 # Limit to freenode nicks
79 if 'freenode' in data[s:e] or 'ubuntu' in data[s:e]:79 if '<strong>irc.freenode.net</strong>' in data[s:e] or '<strong>irc.ubuntu.com</strong>' in data[s:e]:
80 ircnames.append(data[s:e])80 ircnames.append(data[s:e])
81 del data[s:e]81 del data[s:e]
82 except:82 except:

Subscribers

People subscribed via source and target branches