Merge lp:~stefanor/ibid/nickserv-340728 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
Approved revision: 698
Merged at revision: 693
Proposed branch: lp:~stefanor/ibid/nickserv-340728
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/nickserv-340728
Reviewer Review Type Date Requested Status
Michael Gorven Approve
Jonathan Hitchcock Approve
Review via email: mp+8318@code.launchpad.net

This proposal supersedes a proposal from 2009-07-06.

To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

Thoughts?

Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

> Thoughts?

My thoughts:
* This should be included in the default config. Commented out?
* I'm not mad about nickserv_connection.

Revision history for this message
Jonathan Hitchcock (vhata) wrote : Posted in a previous version of this proposal

> Thoughts?

I'm not keen on the hardcoding of "NickServ" either - that should be configurable...

Revision history for this message
Jonathan Hitchcock (vhata) wrote :

Do it.

If other nickserv types crop up, people can file bugs and we'll refine the plugin.

review: Approve
Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

review: Approve
lp:~stefanor/ibid/nickserv-340728 updated
699. By Stefano Rivera

Ensure IRC source

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid.ini'
2--- ibid.ini 2009-05-31 08:10:44 +0000
3+++ ibid.ini 2009-07-07 15:35:05 +0000
4@@ -12,9 +12,13 @@
5 type = irc
6 server = za.atrum.org
7 modes = B
8+# nickserv_password = password
9+ nickserv_mask = services@atrum.org
10 [[freenode]]
11 type = irc
12 server = chat.eu.freenode.net
13+# nickserv_password = password
14+ nickserv_mask = NickServ@services.
15 disabled = True
16 [[jabber]]
17 ssl = True
18@@ -55,7 +59,7 @@
19 object_path = /org/ibid/module/Ping
20 [[core]]
21 names = $botname, bot, ant
22- ignore = NickServ,
23+ ignore = ,
24 [[bzr]]
25 source = atrum
26 channel = "#ibid"
27@@ -77,3 +81,5 @@
28
29 [databases]
30 ibid = sqlite:///ibid.db
31+
32+# vi: set et sta sw=4 ts=4:
33
34=== modified file 'ibid/config.ini'
35--- ibid/config.ini 2009-04-17 23:49:41 +0000
36+++ ibid/config.ini 2009-07-06 14:13:24 +0000
37@@ -17,7 +17,7 @@
38 cachedir = /tmp/ibid
39 [[core]]
40 names = $botname, bot, ant
41- ignore = NickServ,
42+ ignore = ,
43
44 [databases]
45 ibid = sqlite:///ibid.db
46
47=== modified file 'ibid/plugins/irc.py'
48--- ibid/plugins/irc.py 2009-03-16 20:55:20 +0000
49+++ ibid/plugins/irc.py 2009-07-07 15:45:24 +0000
50@@ -1,7 +1,12 @@
51 """Administrative commands for IRC"""
52
53+from fnmatch import fnmatch
54+import logging
55+
56 import ibid
57-from ibid.plugins import Processor, match, authorise
58+from ibid.plugins import Processor, match, handler, authorise
59+
60+log = logging.getLogger('plugins.irc')
61
62 help = {"irc": u"Provides commands for joining/parting channels on IRC and Jabber, and changing the bot's nick"}
63
64@@ -60,4 +65,30 @@
65 source.change_nick(nick)
66 event.addresponse(u'Changing nick to %s', nick)
67
68+class NickServ(Processor):
69+ event_types = ('notice',)
70+
71+ def is_nickserv(self, event):
72+ source_cfg = ibid.config['sources'][event.source]
73+ return (event.sender.get('nick') ==
74+ source_cfg.get(u'nickserv_nick', u'NickServ') and
75+ fnmatch(event.sender['connection'].split('!', 1)[1],
76+ source_cfg.get(u'nickserv_mask', '*')
77+ ))
78+
79+ @match(r'^(?:This nickname is registered\. Please choose a different nickname'
80+ r'|This nickname is registered and protected\. If it is your'
81+ r'|If this is your nickname, type \/msg NS)')
82+ def auth(self, event):
83+ if self.is_nickserv(event):
84+ source_cfg = ibid.config['sources'][event.source]
85+ if u'nickserv_password' in source_cfg:
86+ event.addresponse(u'IDENTIFY %s', source_cfg[u'nickserv_password'])
87+
88+ @match(r'^(?:You are now identified for'
89+ r'|Password accepted -+ you are now recognized)')
90+ def success(self, event):
91+ if self.is_nickserv(event):
92+ log.info(u'Authenticated with NickServ')
93+
94 # vi: set et sta sw=4 ts=4:
95
96=== modified file 'ibid/plugins/log.py'
97--- ibid/plugins/log.py 2009-07-04 23:45:41 +0000
98+++ ibid/plugins/log.py 2009-07-06 14:16:40 +0000
99@@ -20,6 +20,8 @@
100 u'%(year)d/%(month)02d/%(day)02d %(hour)02d:%(minute)02d:%(second)02d <%(sender_nick)s> %(message)s')
101 action_format = Option('action_format', 'Format string for actions',
102 u'%(year)d/%(month)02d/%(day)02d %(hour)02d:%(minute)02d:%(second)02d * %(sender_nick)s %(message)s')
103+ notice_format = Option('notice_format', 'Format string for notices',
104+ u'%(year)d/%(month)02d/%(day)02d %(hour)02d:%(minute)02d:%(second)02d -%(sender_nick)s- %(message)s')
105 presence_format = Option('presence_format', 'Format string for presence events',
106 u'%(year)d/%(month)02d/%(day)02d %(hour)02d:%(minute)02d:%(second)02d %(sender_nick)s (%(sender_connection)s) is now %(state)s')
107 logs = {}
108@@ -50,13 +52,14 @@
109 return self.logs[filename][0]
110
111 def log_event(self, event):
112- if event.type in ('message', 'state', 'action'):
113+ if event.type in ('message', 'state', 'action', 'notice'):
114 when = localtime(event.time)
115
116 format = {
117 'message': self.message_format,
118 'state': self.presence_format,
119 'action': self.action_format,
120+ 'notice': self.notice_format,
121 }[event.type]
122
123 fields = {

Subscribers

People subscribed via source and target branches