#!/usr/bin/env python #Copyright 2004 Sebastian Hagen # This file is part of eucharis. # eucharis is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation # eucharis is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with eucharis; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import socket_management import irc_client import input_handlers class snotice_dumper(input_handlers.handlers_user): def __init__(self, irc_client): self.connections = { 'irc_client':irc_client, } self.handler_bindings = { 'irc_client':[ ['statechange_connection', 'up', self.irc_init_handler, []], ['snotice', None, self.process_snotice_event, []], ] } self.handlers_modify(action='register') self.logger = logging.getLogger('snotice_dumper') def self_op(self, output): output(command='OPER', arguments=['eucharis_drone', '_3b5a21bb8d81c24c4c9a16cc8d5d1Y6']) def irc_init_handler(self, parent, output, event_type, event, permissions, data): if ((event_type == 'statechange_connection') and (event == 'up')): self.self_op(output=output) def process_snotice_event(self, parent, output, event_type, event, permissions, data): self.logger.log(20, 'DO3 %s' % (data,)) ic1 = irc.client_irc_client(('192.168.0.10', 6667), nick='eucharis_drone', username='drone', realname='eucharis_drone', umodes=['x'], channels=['#level5hyperspace']) ic1.connection_init() usnp1 = snotice_dumper(irc_client=ic1) import logging.handlers logger = logging.getLogger() logger.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') handler_stderr = logging.StreamHandler() handler_stderr.setLevel(logging.INFO) handler_stderr.setFormatter(formatter) logger.addHandler(handler_stderr) handler_file = logging.handlers.RotatingFileHandler('client_log', 'a', 1048576, 2) handler_file.doRollover() handler_file.setLevel(logging.DEBUG) handler_file.setFormatter(formatter) logger.addHandler(handler_file) socket_management.select_loop()