Merge lp:~ddormer/kali/887467-fjoin-modes into lp:kali

Proposed by Darren Dormer on 2013-05-27
Status: Needs review
Proposed branch: lp:~ddormer/kali/887467-fjoin-modes
Merge into: lp:kali
Diff against target: 120 lines (+32/-10)
2 files modified
kali/controller.py (+10/-6)
kali/protocol.py (+22/-4)
To merge this branch: bzr merge lp:~ddormer/kali/887467-fjoin-modes
Reviewer Review Type Date Requested Status
Kali Developers 2013-05-27 Pending
Review via email: mp+165895@code.launchpad.net
To post a comment you must log in.
lp:~ddormer/kali/887467-fjoin-modes updated on 2013-05-27
140. By Darren Dormer on 2013-05-27

Added mode parameter.

Unmerged revisions

140. By Darren Dormer on 2013-05-27

Added mode parameter.

139. By Darren Dormer on 2013-05-27

Removed redundant code

138. By Darren Dormer on 2013-05-27

- Fixed a couple docstring typos.
- Fixed FJOIN.
- Added ':' back to the trailing arguments to allow the detection of optional trailing arguments.

137. By Darren Dormer on 2012-09-02

- Added modes paremeter to irc_FJOIN

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'kali/controller.py'
2--- kali/controller.py 2012-01-15 17:02:41 +0000
3+++ kali/controller.py 2013-05-27 15:38:24 +0000
4@@ -201,7 +201,7 @@
5 self.ctrl = controller
6 self.store = self.ctrl.store
7 self.cid = ''.join(n for n in self.ctrl.ids.next())
8- self.uid = self.ctrl.params['sid'] + self.cid
9+ self.uid = self.ctrl.params['sid'] + self.cid
10 self.avatars = {}
11
12 def event_connected(self, protocol):
13@@ -324,6 +324,7 @@
14 super(User, self).__init__(*a, **kw)
15 self.registered = False
16 self.channels = set()
17+ self.status = {}
18
19
20 class Channel(record('name'), _ModesMixin):
21@@ -340,7 +341,7 @@
22 @type lists: C{{mode: [values]}}
23
24 @ivar users: The users currently joined to the channel.
25- @type users: C{list}
26+ @type users: C{dict}
27 """
28 def __init__(self, *a, **kw):
29 super(Channel, self).__init__(*a, **kw)
30@@ -456,12 +457,15 @@
31 channel.lists[mode].remove(param)
32
33 def event_userStatusAdded(self, source, target, mode, param):
34- channel = self.getChannel(target)
35- channel.users[param].status.add(mode)
36+ channels = self.getChannel(target).users[param].status
37+ status = channels.get(target, None)
38+ if not status:
39+ status = channels[target] = set()
40+ status.add(mode)
41
42 def event_userStatusRemoved(self, source, target, mode, param):
43 channel = self.getChannel(target)
44- channel.users[param].status.remove(mode)
45+ channel.users[param].status[target].remove(mode)
46
47 def event_joined(self, channelName, nick):
48 try:
49@@ -470,7 +474,7 @@
50 channel = self.channels[channelName] = Channel(channelName)
51
52 user = self.getUser(nick)
53- channel.users[user] = {}
54+ channel.users[nick] = user
55 user.channels.add(channel)
56
57 def event_parted(self, channelName, nick, message):
58
59=== modified file 'kali/protocol.py'
60--- kali/protocol.py 2012-01-05 15:56:39 +0000
61+++ kali/protocol.py 2013-05-27 15:38:24 +0000
62@@ -47,6 +47,7 @@
63
64 if ' :' in s:
65 s, trailing = s.split(' :', 1)
66+ trailing = ':' + trailing
67
68 args = s.split()
69 if trailing:
70@@ -71,7 +72,7 @@
71 @type params: C{list}
72
73 @returns: (added, removed) modes
74- @rtype: C{([(mode, param)], [(mode, param]))}
75+ @rtype: C{([(mode, param)], [(mode, param)])}
76 """
77 if len(modes) == 0:
78 raise IRCBadModes('Empty mode string')
79@@ -346,11 +347,26 @@
80 else:
81 self.services.event('channelFlagUnset', source, target, mode)
82
83- def irc_FJOIN(self, source, channel, timestamp, users):
84+ def irc_FJOIN(self, source, channel, timestamp, modes, *args):
85+ args = list(args)
86+ params = []
87+ if ':' in args[-1]:
88+ users = args.pop().lstrip(':')
89+
90+ params = args
91+ modes = parseModes(modes, params, (self.channelParamModes,''))
92 for user in users.split():
93- prefixes, nick = user.split(',', 1)
94+ try:
95+ prefixes, nick = user.split(',', 1)
96+ except ValueError:
97+ prefixes, nick = None, user
98 self.services.event('joined', channel, nick)
99- # XXX: translate the prefixes into channel mode changes
100+ if prefixes:
101+ for prefix in prefixes:
102+ self.addMode_channel(source, channel, prefix, nick)
103+
104+ for mode in modes[0]:
105+ self.addMode_channel(source, channel, *mode)
106
107 def irc_JOIN(self, source, channels, timestamp):
108 for channel in channels.split(','):
109@@ -374,9 +390,11 @@
110 if len(params) == 1:
111 pass
112 else:
113+ #XXX: modeparams aren't always present.
114 paramNames = 'cid timestamp nick hostname fakehost username ip signontime modes modeparams realname'.split()
115
116 user = dict(zip(paramNames, params))
117+ user['realname'].lstrip(':')
118 user['cid'] = user['cid'].decode('ascii')
119 user['nick'] = user['nick'].decode('ascii')
120 user['modes'] = user['modes'].lstrip('+')

Subscribers

People subscribed via source and target branches

to all changes: