Example #1
0
    def write_minutes(self, event):
        if not event.public:
            event.addresponse(u'Sorry, must be done in public')
            return
        if (event.source, event.channel) not in meetings:
            event.addresponse(u'Sorry, no meeting in progress.')
            return
        meeting = meetings[(event.source, event.channel)]
        meeting['attendees'].update((e['nick'], None) for e in meeting['log']
                                    if e['nick'] not in meeting['attendees']
                                    and e['nick'] != ibid.config['botname'])

        render_to = set()
        if self.logurl is None:
            render_to.add('txt')
        render_to.update(self.formats)
        minutes = {}
        for format in render_to:
            if format == 'json':

                class DTJSONEncoder(json.JSONEncoder):
                    def default(self, o):
                        if isinstance(o, datetime):
                            return o.strftime('%Y-%m-%dT%H:%M:%SZ')
                        return json.JSONEncoder.default(self, o)

                minutes[format] = json.dumps(meeting,
                                             cls=DTJSONEncoder,
                                             indent=2)
            else:
                template = templates.get_template('meetings/minutes.' + format)
                minutes[format] = template.render(meeting=meeting) \
                        .encode('utf-8')

            filename = self.logfile % {
                'source': event.source.replace('/', '-'),
                'channel': meeting['channel'].replace('/', '-'),
                'date': meeting['starttime'].strftime(self.date_format),
                'format': format,
            }
            filename = join(ibid.options['base'], expanduser(filename))
            try:
                makedirs(dirname(filename), int(self.dir_mode, 8))
            except OSError, e:
                if e.errno != EEXIST:
                    raise e
            f = open(filename, 'w+')
            chmod(filename, int(self.file_mode, 8))
            f.write(minutes[format])
            f.close()
Example #2
0
    def write_minutes(self, event):
        if not event.public:
            event.addresponse(u'Sorry, must be done in public')
            return
        if (event.source, event.channel) not in meetings:
            event.addresponse(u'Sorry, no meeting in progress.')
            return
        meeting = meetings[(event.source, event.channel)]
        meeting['attendees'].update((e['nick'], None) for e in meeting['log']
                if e['nick'] not in meeting['attendees']
                and e['nick'] != ibid.config['botname'])

        render_to = set()
        if self.logurl is None:
            render_to.add('txt')
        render_to.update(self.formats)
        minutes = {}
        for format in render_to:
            if format == 'json':
                class DTJSONEncoder(json.JSONEncoder):
                    def default(self, o):
                        if isinstance(o, datetime):
                            return o.strftime('%Y-%m-%dT%H:%M:%SZ')
                        return json.JSONEncoder.default(self, o)
                minutes[format] = json.dumps(meeting, cls=DTJSONEncoder,
                        indent=2)
            else:
                template = templates.get_template('meetings/minutes.' + format)
                minutes[format] = template.render(meeting=meeting) \
                        .encode('utf-8')

            filename = self.logfile % {
                'source': event.source.replace('/', '-'),
                'channel': meeting['channel'].replace('/', '-'),
                'date': meeting['starttime'].strftime(self.date_format),
                'format': format,
            }
            filename = join(ibid.options['base'], expanduser(filename))
            try:
                makedirs(dirname(filename), int(self.dir_mode, 8))
            except OSError, e:
                if e.errno != EEXIST:
                    raise e
            f = open(filename, 'w+')
            chmod(filename, int(self.file_mode, 8))
            f.write(minutes[format])
            f.close()
Example #3
0
 def __init__(self):
     ibid.rpc[self.features[0]] = self
     self.form = templates.get_template('plugin_form.html')
     self.list = templates.get_template('plugin_functions.html')