#!/usr/bin/env python #Copyright 2004,2007 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 os import sys import time import re import logging import random import basic_io import socket_management import irc_server def irc_server_debug_handler(irc_server, output, event, event_type, permissions, data): source = data['source'] command = data['command'] arguments = data['arguments'] text = arguments[-1] if (len(arguments) < 1): return 0 target = arguments[0] if ((target == '') or (target[0] != '#')): return 0 text_split = text.split() text_command_1 = text_split[0] if (len(text) > 1): text_command_2 = text_split[1] else: text_command_2 = None if (len(text) > 2): text_arguments = text_split[2:] else: text_arguments = [] if (text_command_1 == '!Lapis'): if (text_command_2 == 'dump_channels'): for channel in irc_server.network_channels: output(source=None, command='PRIVMSG', arguments=[target], text=str(channel) + ':' + str(irc_server.network_channels[channel])) if ((text_command_2 == 'dump_channel') and (text_arguments[0] in irc_server.network_channels)): channel = text_arguments[0] output(source=None, command='PRIVMSG', arguments=[target], text=str(channel) + ':' + str(irc_server.network_channels[channel])) elif (text_command_2 == 'dump_nicks'): for nick in irc_server.network_nicks: output(source=None, command='PRIVMSG', arguments=[target], text=str(nick) + ':' + str(irc_server.network_nicks[nick])) if ((text_command_2 == 'dump_nick') and (text_arguments[0] in irc_server.network_nicks)): nick = text_arguments[0] output(source=None, command='PRIVMSG', arguments=[target], text=str(nick) + ':' + str(irc_server.network_nicks[nick])) elif (text_command_2 == 'dump_servers'): for server in irc_server.network_servers: output(source=None, command='PRIVMSG', arguments=[target], text=str(server) + ':' + str(irc_server.network_servers[server])) if ((text_command_2 == 'dump_server') and (text_arguments[0] in irc_server.network_servers)): server = text_arguments[0] output(source=None, command='PRIVMSG', arguments=[target], text=str(server) + ':' + str(irc_server.network_servers[server])) #is1 = irc_server.irc_server(servername='experimental.platform.01', address=('192.168.0.10', 6667), password_out=FIXME_PASS1, auth_dictionary={'grey_cat':[FIXME_PASS2, ['a','o','secondary operator']]}, primary_nick='Lapis') #is1.local_nicks_add(nick='Lapis', username='Lapis', agressive=1, host='experimental_vessel', realname='Lapis Lazuli', channels=['#level5hyperspace'], flags={'#level5hyperspace':['o','a'], '#lobby':['o','a']}, timestamp=0) #is1.handlers.add(event_type='command', event='PRIVMSG', handler=irc_server_debug_handler) #is1.handlers.add(event_type='command', event='NOTICE', handler=irc_server_debug_handler) #is1.connection_init() #socket_management.select_loop()