Merge lp:~gingerchris/endroid/bugfixes into lp:endroid

Proposed by ChrisD
Status: Merged
Approved by: Martin Morrison
Approved revision: no longer in the source branch.
Merged at revision: 66
Proposed branch: lp:~gingerchris/endroid/bugfixes
Merge into: lp:endroid
Diff against target: 61 lines (+31/-6)
2 files modified
src/endroid/usermanagement.py (+15/-3)
src/endroid/wokkelhandler.py (+16/-3)
To merge this branch: bzr merge lp:~gingerchris/endroid/bugfixes
Reviewer Review Type Date Requested Status
Martin Morrison Approve
Review via email: mp+185287@code.launchpad.net

Commit message

Some bug fixes:
 * Add errback to the kick deferred
 * Improve the message identification code

Description of the change

Some bug fixes:
 * Add errback to the kick deferred
 * Improve the message identification code

To post a comment you must log in.
Revision history for this message
Martin Morrison (isoschiz) wrote :

- Successful only has one l

review: Needs Fixing
Revision history for this message
Martin Morrison (isoschiz) :
review: Approve
lp:~gingerchris/endroid/bugfixes updated
65. By Simon C

Remove trailing whitespace from exec plugin output

66. By Chris Davidson <email address hidden>

Some bug fixes:
 * Add errback to the kick deferred
 * Improve the message identification code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/endroid/usermanagement.py'
2--- src/endroid/usermanagement.py 2013-09-11 11:12:08 +0000
3+++ src/endroid/usermanagement.py 2013-09-12 16:00:33 +0000
4@@ -527,9 +527,21 @@
5 return d
6
7 def kick(self, room, nick, reason=None):
8- """Kick the user with the specified nick from the room."""
9- logging.debug("Kicking {} from {}".format(nick, room))
10- self.wh.kick(JID(room), nick, reason)
11+ """
12+ Kick the user with the specified nick from the room.
13+
14+ Returns a deferred which can be monitored to determine if the kick was
15+ successful.
16+
17+ """
18+
19+ def success(_):
20+ logging.info("Kicked {} from {} ({})".format(nick, room, reason))
21+ def failure(_):
22+ logging.error("Failed to kick {} from {} ({})".format(
23+ nick, room, reason))
24+
25+ return self.wh.kick(JID(room), nick, reason).addCallbacks(success, failure)
26
27 def joined_room(self, name):
28 logging.info("Joined room {}".format(name))
29
30=== modified file 'src/endroid/wokkelhandler.py'
31--- src/endroid/wokkelhandler.py 2013-09-10 17:56:41 +0000
32+++ src/endroid/wokkelhandler.py 2013-09-12 16:00:33 +0000
33@@ -98,13 +98,26 @@
34 logging.info('SUC Message received from {}'.format(
35 sender.full()))
36 self.messagehandler.receive_chat(m)
37- else:
38- if message.children[0].children[0].name == "invite":
39- ujid = message.children[0].children[0].attributes['from']
40+ elif len(message.children) > 0:
41+ # Try and identify this message type
42+ msg_child = message.children[0]
43+ if (msg_child.name == 'x' and len(msg_child.children) > 0 and
44+ msg_child.children[0].name == 'invite'):
45+ # Looks like an invite
46+ ujid = msg_child.children[0].attributes['from']
47 rjid = message.attributes['from']
48 logging.info("Invitation received to " + rjid + " from " + ujid)
49 logging.info(("Rejected. To enable uncomment receiving "
50 "line and enable InviteBot"))
51+ elif (msg_child.name == 'body' and len(msg_child.children) > 0 and
52+ 'granted' in msg_child.children[0]):
53+ logging.info("Received affiliation change message: {}".format(
54+ msg_child.children[0]))
55+ else:
56+ logging.error("Received unknown message with child: "
57+ "{}".format(message.toXml()))
58+ else:
59+ logging.error("Received unknown message: {}".format(message.toXml()))
60
61 # MUCClient methods to be overridden
62

Subscribers

People subscribed via source and target branches