Merge lp:~tsimpson/ubuntu-bots/ircd-seven into lp:~tsimpson/ubuntu-bots/tweak

Proposed by Terence Simpson
Status: Merged
Approved by: Terence Simpson
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~tsimpson/ubuntu-bots/ircd-seven
Merge into: lp:~tsimpson/ubuntu-bots/tweak
Diff against target: 113 lines (+72/-19)
2 files modified
IRCLogin/config.py (+1/-1)
IRCLogin/plugin.py (+71/-18)
To merge this branch: bzr merge lp:~tsimpson/ubuntu-bots/ircd-seven
Reviewer Review Type Date Requested Status
Terence Simpson Approve
Review via email: mp+18294@code.launchpad.net

Commit message

To post a comment you must log in.
Revision history for this message
Terence Simpson (tsimpson) wrote :

Migrate to IRCd-Seven

Revision history for this message
Terence Simpson (tsimpson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'IRCLogin/config.py'
2--- IRCLogin/config.py 2009-11-04 03:50:49 +0000
3+++ IRCLogin/config.py 2010-01-30 07:35:22 +0000
4@@ -22,5 +22,5 @@
5 IRCLogin = conf.registerPlugin('IRCLogin')
6 conf.registerGlobalValue(IRCLogin, 'UserList',
7 registry.String('', """Filename of file with list of users""",private=True))
8-conf.registerGloblalValue(IRCLogin, "teamname",
9+conf.registerGlobalValue(IRCLogin, "teamname",
10 registry.String('ubuntu-irc', "Name of the Launchpad team to get users from", private=True))
11
12=== modified file 'IRCLogin/plugin.py'
13--- IRCLogin/plugin.py 2009-12-03 23:23:09 +0000
14+++ IRCLogin/plugin.py 2010-01-30 07:35:22 +0000
15@@ -204,27 +204,80 @@
16 self._callCommand(["login"], irc, msg, [])
17
18 def do290(self, irc, msg):
19- assert 'IDENTIFY-MSG' in msg.args[1]
20- irc.getRealIrc()._Freenode_capabed = True
21-
22- def do376(self, irc, msg):
23- irc.queueMsg(ircmsgs.IrcMsg('CAPAB IDENTIFY-MSG'))
24- def do422(self, irc, msg): # MOTD missing
25- irc.queueMsg(ircmsgs.IrcMsg('CAPAB IDENTIFY-MSG'))
26+ """hyperiron CAPAB reply"""
27+ realIrc = irc.getRealIrc()
28+ realIrc._Freenode_capabed_notices = False
29+ if msg.args[1].lower() == "identify-msg":
30+ realIrc._Freenode_capabed = True
31+ else:
32+ realIrc._Freenode_capabed = Dalse
33+
34+ def doCap(self, irc, msg):
35+ """ircd-seven CAP reply"""
36+ cmd = msg.args[1].lower()
37+ args = msg.args[2].lower()
38+ realIrc = irc.getRealIrc()
39+ if cmd == "ls": # Got capability listing
40+ if "identify-msg" in args: # identify-msg is a capability on this server
41+ irc.queueMsg(ircmsgs.IrcMsg('CAP REQ IDENTIFY-MSG')) # Request identify-msg
42+
43+ if cmd == "ack": # Acknowledge reply
44+ if "identify-msg" in args: # identify-msg is set
45+ realIrc._Freenode_capabed = True
46+ realIrc._Freenode_capabed_notices = True
47+
48+ if cmd == 'nak': # Failure reply
49+ if "identify-msg" in args: # identify-msg is not set
50+ realIrc._Freenode_capabed = False
51+ realIrc._Freenode_capabed_notices = False
52+
53+ def do421(self, irc, msg):
54+ """Invalid command"""
55+ if msg.args[1].lower() == "cap":
56+ irc.queueMsg(ircmsgs.IrcMsg("CAPAB IDENTIFY MSG"))
57+
58+ def do376(self, irc, msg, force=False): # End of /MOTD command.
59+ """
60+ The new freenode ircd-seven requires using the 'CAP' command
61+ to set capabilities, rather than hyperirons 'CAPAB' command.
62+ You request "CAP REQ IDENTIFY-MSG" and the server will respond
63+ with either "CAP <nick> ACK :identify-msg" to acknowledge, or
64+ "CAP <nick> NAK :identify-msg" to indicate failure.
65+ Other than that, it's the same.
66+ """
67+ if not hasattr(irc.getRealIrc(), "_Freenode_capabed") and not force: # Do this only once
68+ realIrc = irc.getRealIrc()
69+ realIrc._Freenode_capabed = False
70+ realIrc._Freenode_capabed_notices = False
71+ # Try the CAP command first
72+ irc.ququeMsg(ircmsgs.IrcMsg("CAP LS"))
73+
74+ do422 = do376
75
76 def inFilter(self, irc, msg):
77- if not msg.command == "PRIVMSG":
78- return msg
79- if getattr(irc,'_Freenode_capabed',None) and msg.command == 'PRIVMSG':
80- if msg.tagged('identified') == None:
81- first = msg.args[1][0]
82- rest = msg.args[1][1:]
83- msg.tag('identified', first == '+')
84- if first in ('+', '-'):
85- msg = ircmsgs.privmsg(msg.args[0], rest, msg=msg)
86- assert msg.receivedAt and msg.receivedOn and msg.receivedBy
87+ """
88+ Strip the leading '+' or '-' from each message
89+ """
90+
91+ if msg.command not in ("PRIVMSG", "NOTICE"):
92+ return msg
93+
94+ if not getattr(irc, '_Freenode_capabed', False):
95+ return msg
96+
97+ if msg.command == "NOTICE" and not getattr(irc, '_Freenode_capabed_notices', False):
98+ return msg
99+
100+ if msg.tagged('identified') == None:
101+ first = msg.args[1][0]
102+ rest = msg.args[1][1:]
103+ msg.tag('identified', first == '+')
104+ if first in ('+', '-'):
105+ msg = ircmsgs.privmsg(msg.args[0], rest, msg=msg)
106+ assert msg.receivedAt and msg.receivedOn and msg.receivedBy
107+
108 if len(msg.args) >= 2 and msg.args[1] and msg.args[1][0] in ('+', '-'):
109- self.do376(irc, msg)
110+ self.do376(irc, msg, True)
111 return msg
112
113 Class = IRCLogin

Subscribers

People subscribed via source and target branches