Add %(channel) replacement to filenames
- Allows configuration of saving on a per-network basis. darcs-hash:20091125085704-82ea9-6068d1ae3eb521f19447c6e07f8dd46390ad6868.gz
This commit is contained in:
parent
67e7a2b4f3
commit
534c6842b1
@ -452,11 +452,11 @@ These variables are set either in ``meetingLocalConfig.py`` (in the
|
|||||||
``logFileDir`` and ``logUrlPrefix``.
|
``logFileDir`` and ``logUrlPrefix``.
|
||||||
|
|
||||||
Variables available for replacement using ``%(name)s`` include:
|
Variables available for replacement using ``%(name)s`` include:
|
||||||
``channel``, ``meetingname``. Double percent signs (e.g.: ``%%Y``
|
``channel``, ``network``, ``meetingname``. Double percent signs
|
||||||
are time formats, from ``time.strftime``.
|
(e.g.: ``%%Y`` are time formats, from ``time.strftime``.
|
||||||
|
|
||||||
This filename does *not* include extensions. Those are found from
|
You should *not* include filename extensions here. Those are
|
||||||
the writers, via the variable ``writer_map``.
|
found from the writers, via the variable ``writer_map``.
|
||||||
|
|
||||||
Putting these all together, a set of variables could be:
|
Putting these all together, a set of variables could be:
|
||||||
1) ``logFileDir = /srv/www/meetings/``
|
1) ``logFileDir = /srv/www/meetings/``
|
||||||
|
@ -148,11 +148,13 @@ class Config(object):
|
|||||||
else:
|
else:
|
||||||
pattern = self.filenamePattern
|
pattern = self.filenamePattern
|
||||||
channel = self.M.channel.strip('# ').lower().replace('/', '')
|
channel = self.M.channel.strip('# ').lower().replace('/', '')
|
||||||
|
network = self.M.network.strip(' ').lower().replace('/', '')
|
||||||
if self.M._meetingname:
|
if self.M._meetingname:
|
||||||
meetingname = self.M._meetingname.replace('/', '')
|
meetingname = self.M._meetingname.replace('/', '')
|
||||||
else:
|
else:
|
||||||
meetingname = channel
|
meetingname = channel
|
||||||
path = pattern%locals()
|
path = pattern%{'channel':channel, 'network':network,
|
||||||
|
'meetingname':meetingname}
|
||||||
path = time.strftime(path, self.M.starttime)
|
path = time.strftime(path, self.M.starttime)
|
||||||
# If we want the URL name, append URL prefix and return
|
# If we want the URL name, append URL prefix and return
|
||||||
if url:
|
if url:
|
||||||
@ -428,7 +430,7 @@ class Meeting(MeetingCommands, object):
|
|||||||
filename=None, writeRawLog=False,
|
filename=None, writeRawLog=False,
|
||||||
setTopic=None, sendReply=None, getRegistryValue=None,
|
setTopic=None, sendReply=None, getRegistryValue=None,
|
||||||
safeMode=False, channelNicks=None,
|
safeMode=False, channelNicks=None,
|
||||||
extraConfig={}):
|
extraConfig={}, network='nonetwork'):
|
||||||
self.config = Config(self, writeRawLog=writeRawLog, safeMode=safeMode,
|
self.config = Config(self, writeRawLog=writeRawLog, safeMode=safeMode,
|
||||||
extraConfig=extraConfig)
|
extraConfig=extraConfig)
|
||||||
if getRegistryValue is not None:
|
if getRegistryValue is not None:
|
||||||
@ -439,6 +441,7 @@ class Meeting(MeetingCommands, object):
|
|||||||
self._setTopic = setTopic
|
self._setTopic = setTopic
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
|
self.network = network
|
||||||
self.currenttopic = ""
|
self.currenttopic = ""
|
||||||
if oldtopic:
|
if oldtopic:
|
||||||
self.oldtopic = self.config.dec(oldtopic)
|
self.oldtopic = self.config.dec(oldtopic)
|
||||||
@ -540,6 +543,8 @@ class Meeting(MeetingCommands, object):
|
|||||||
self.minutes.append(m)
|
self.minutes.append(m)
|
||||||
def replacements(self):
|
def replacements(self):
|
||||||
repl = { }
|
repl = { }
|
||||||
|
repl['channel'] = self.channel
|
||||||
|
repl['network'] = self.network
|
||||||
repl['MeetBotInfoURL'] = self.config.MeetBotInfoURL
|
repl['MeetBotInfoURL'] = self.config.MeetBotInfoURL
|
||||||
repl['timeZone'] = self.config.timeZone
|
repl['timeZone'] = self.config.timeZone
|
||||||
repl['starttime'] = repl['endtime'] = "None"
|
repl['starttime'] = repl['endtime'] = "None"
|
||||||
|
@ -74,6 +74,7 @@ class MeetBot(callbacks.Plugin):
|
|||||||
nick = msg.nick
|
nick = msg.nick
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
payload = msg.args[1]
|
payload = msg.args[1]
|
||||||
|
network = irc.msg.tags['receivedOn']
|
||||||
|
|
||||||
# The following is for debugging. It's excellent to get an
|
# The following is for debugging. It's excellent to get an
|
||||||
# interactive interperter inside of the live bot. use
|
# interactive interperter inside of the live bot. use
|
||||||
@ -85,7 +86,7 @@ class MeetBot(callbacks.Plugin):
|
|||||||
# Get our Meeting object, if one exists. Have to keep track
|
# Get our Meeting object, if one exists. Have to keep track
|
||||||
# of different servers/channels.
|
# of different servers/channels.
|
||||||
# (channel, network) tuple is our lookup key.
|
# (channel, network) tuple is our lookup key.
|
||||||
Mkey = (channel,irc.msg.tags['receivedOn'])
|
Mkey = (channel,network)
|
||||||
M = meeting_cache.get(Mkey, None)
|
M = meeting_cache.get(Mkey, None)
|
||||||
|
|
||||||
# Start meeting if we are requested
|
# Start meeting if we are requested
|
||||||
@ -106,10 +107,11 @@ class MeetBot(callbacks.Plugin):
|
|||||||
setTopic = _setTopic, sendReply = _sendReply,
|
setTopic = _setTopic, sendReply = _sendReply,
|
||||||
getRegistryValue = self.registryValue,
|
getRegistryValue = self.registryValue,
|
||||||
safeMode=True, channelNicks=_channelNicks,
|
safeMode=True, channelNicks=_channelNicks,
|
||||||
|
network=network,
|
||||||
)
|
)
|
||||||
meeting_cache[Mkey] = M
|
meeting_cache[Mkey] = M
|
||||||
recent_meetings.append(
|
recent_meetings.append(
|
||||||
(channel, irc.msg.tags['receivedOn'], time.ctime()))
|
(channel, network, time.ctime()))
|
||||||
if len(recent_meetings) > 10:
|
if len(recent_meetings) > 10:
|
||||||
del recent_meetings[0]
|
del recent_meetings[0]
|
||||||
# If there is no meeting going on, then we quit
|
# If there is no meeting going on, then we quit
|
||||||
|
@ -223,6 +223,28 @@ class MeetBotTest(unittest.TestCase):
|
|||||||
self.assert_('<link rel="stylesheet" ' not in results['.log.html'])
|
self.assert_('<link rel="stylesheet" ' not in results['.log.html'])
|
||||||
self.assert_('<style type="text/css" ' not in results['.log.html'])
|
self.assert_('<style type="text/css" ' not in results['.log.html'])
|
||||||
|
|
||||||
|
def test_filenamevars(self):
|
||||||
|
def getM(fnamepattern):
|
||||||
|
M = meeting.Meeting(channel='somechannel',
|
||||||
|
network='somenetwork',
|
||||||
|
owner='nobody',
|
||||||
|
extraConfig={'filenamePattern':fnamepattern})
|
||||||
|
M.addline('nobody', '#startmeeting')
|
||||||
|
return M
|
||||||
|
# Test the %(channel)s and %(network)s commands in supybot.
|
||||||
|
M = getM('%(channel)s-%(network)s')
|
||||||
|
assert M.config.filename().endswith('somechannel-somenetwork'), \
|
||||||
|
"Filename not as expected: "+M.config.filename()
|
||||||
|
# Test dates in filenames
|
||||||
|
M = getM('%(channel)s-%%F')
|
||||||
|
import time
|
||||||
|
assert M.config.filename().endswith(time.strftime('somechannel-%F')),\
|
||||||
|
"Filename not as expected: "+M.config.filename()
|
||||||
|
# Test #meetingname in filenames
|
||||||
|
M = getM('%(channel)s-%(meetingname)s')
|
||||||
|
M.addline('nobody', '#meetingname blah1234')
|
||||||
|
assert M.config.filename().endswith('somechannel-blah1234'),\
|
||||||
|
"Filename not as expected: "+M.config.filename()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user