#!/usr/bin/env python #Copyright 2004,2005 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 input_handlers from iptracking import core_base class irc_server_debug_handler(input_handlers.handlers_user, core_base): def __init__(self, irc_server): self.handler_bindings = { 'irc_server':[ ['trigger', 'debug', self.irc_server_debug_handler, ['o']], ] } core_base.__init__(self, irc_server=irc_server) self.handlers_modify(action='register') def irc_server_debug_handler(self, irc_server, output, event_type, event, permissions, data): source = data['source'] command = data['command'] arguments = data['arguments'] reply_target = data['reply_target'] if (len(arguments) > 0): command_2 = arguments[0] arguments = arguments[1:] else: return 1 output_data = None if (len(arguments) > 0): if ((command_2 == 'dump_server') and (arguments[0] in irc_server.network_servers)): output_data = irc_server.network_servers[arguments[0]] elif ((command_2 == 'dump_nick') and (arguments[0] in irc_server.network_nicks)): output_data = irc_server.network_nicks[arguments[0]] elif ((command_2 == 'dump_channel') and (arguments[0] in irc_server.network_channels)): output_data = irc_server.network_channels[arguments[0]] if (type(output_data) == dict): output(command='PRIVMSG', arguments=[reply_target, '%s: %s' % (arguments[0], output_data)]) output_data = None if (command_2 == 'dump_channels'): output_data = irc_server.network_channels elif (command_2 == 'dump_nicks'): output_data = irc_server.network_nicks elif (command_2 == 'dump_servers'): output_data = irc_server.network_servers elif (command_2 == 'cdns'): asynchronous_processing.gethostbyname(arguments[0], callback_handler=self.debug1_out, callback_kwargs={'callback_data': {1:2,3:4}}) elif (command_2 == 'aexec'): asynchronous_processing.child_execute(command_string=arguments, callback_target=self.debug2_out, callback_kwargs={'callback_data':{None:'alpha','test':2}}) if (type(output_data) == dict): for key in output_data: output(command='PRIVMSG', arguments=[reply_target, '%s: %s' % (key, output_data[key])]) def debug1_out(self, request, response, callback_data): print 'DO1', time.time(), self, request, response, callback_data def debug2_out(self, child_stdout, child_stderr, child_return_value, callback_data): print 'DO2', time.time(), self, child_stdout, child_stderr, child_return_value, callback_data