IRCserver Module

A simple IRC server.
From TP1 of MPRI Courses “Net Project”. Ex2 (QU3) (QU4) (QU5) (QU6)

Warning

This script is deprecated, don’t use it.

./IRCserver.py [HOST PORT [OPTIONS]] | -z [OPTIONS]

Create a server listening on HOST at PORT, and run it as a server which accepts client on it and broadcast every message from on client to all the other clients.

Options:

  • –interactive, -i, -z, –zenity Force Zenity interactivity : read args HOST and PORT interactively,

    with Zenity and PyZenity (don’t use it unless you are sure to have both).

  • -ni, --non-interactive
     

    Disable Zenity interactivity : read args HOST and PORT from command line, Default.

  • -h,–help Print this help message.

  • -a

    Print all message incomming from the client or outcomming to the server with verbous information.

  • –debug Launch program in debug mod with pygdb.

Example:

$ ./PyRlwrap.py ./IRCserver.py naereen-corp.crans.org 9312 -a

Copyrigths:

  1. 09/2012
By Lilian BESSON
ENS de Cachan (M1 Mathematics & M1 Computer Science MPRI) mailto:lbesson@ens-cachan.fr
For Naereen Corp.
mailto:naereen-corporation@laposte.net https:sites.google.com/site/naereencorp/liste-des-projets/irc.
IRCserver.ColorOff(verb=False)[source]

Turn off the support of ANSI Colors. Can be used other somewhere else, or on other modules, AFTER importing ANSIColors module !

IRCserver.ColorOn(verb=False)[source]

Turn on the support of ANSI Colors. Can be used other somewhere else, or on other modules, AFTER importing ANSIColors module !

IRCserver.exit_with_Zenity(msg_erreur)[source]

A remplacement for sys.exit : print an error message with Zenity before executing sys.exit.

IRCserver.PRINT_ALL_MESSAGE = 1

1 to print messages

IRCserver.LISTEN_NB_CST = 16

Nb of input socket authorized (a max)

IRCserver.create_bind_socket(server=('127.0.0.1', 2048))[source]

Create a socket and bind it to the port @port and the addresse @host.

IRCserver.create_data_socket(listen_socket, NB_CLIENT=0)[source]

Create a data socket from the socket @listen_socket.

IRCserver.WRAPPER_OUT = '$:OUT: '

Piece of text to be printed before each output.

IRCserver.WRAPPER_IN = ':IN:$ '

Piece of text to be printed before each input.

IRCserver.broadcast_message_list(message='No message was gave', list_client=[], origin='UNKNOW', PRINT_ALL_MESSAGE=1)[source]

Broadcast the message @message to each of the client in a list of client @list_client. @origin permits to print some usefull informations for delivering the origin of the message the all connected clients.

IRCserver.help_User = '\nWelcome in IRC server v0.95.\n\tWrote by Lilian BESSON (mailto:lilian.besson@normale.fr), last version dated of jeudi 07 02 2013, at 23h:17m:30s.\n\tWrote in Python 2.6+, using PyZenity for interactive interface, and ANSIColors for colors in output messages.\n\tReference page for this software is : https://sites.google.com/site/naereencorp/liste-des-projets/irc.\n\nYour are an IRC server, which accepts client using UDP sockets.\nAll messages enter from here will be broadcasted to all connected clients, and here are printed all messages from other clients, connection and disconnection of clients, and more.\n\nThe following commands are enabled :\n\t\\h, \\help, \\? : print this help,\n\t\\out : logout (as like Ctrl+D),\n\t\\kill <ADDR, PORT> : close manually the clients registering with (ADDR, PORT).\n\t /!\\ NOT YET IMPLEMENTED FIXME\n'

The help message, which can be printed to the user when invoking ‘\?’

IRCserver.action_on_readstr(readstr)[source]

Reaction to special message readed from the keyboard !

IRCserver.irc_server(server=('127.0.0.1', 2048), PRINT_ALL_MESSAGE=1)[source]
Create a server with addr,port=@server, listening on HOST at PORT,
and run it as a server which accepts client on it and broadcast every message from on client to all the other clients. Returns the socket_server when all connections are closed or the server decides to close himself.

Attention : to be respectuous of TCP conventions, if the connection is closed from the server stdin (Ctrl + C), the returned socket has to be closed by the programmer.

DEBUG, PRINT_ALL_MESSAGE: are options for parametrize behaviour of client.

IRCserver.HELP = "./IRCserver.py [HOST PORT [OPTIONS]] | -z [OPTIONS]\n\nCreate a server listening on HOST at PORT, and run it as a server which accepts client on it and broadcast every message from on client to all the other clients.\n\nOptions:\n========\n *\t--interactive, -i, -z, --zenity\tForce Zenity interactivity : read args HOST and PORT interactively,\n\t\t with Zenity and PyZenity (don't use it unless you are sure to have both).\n *\t-ni, --non-interactive\tDisable Zenity interactivity : read args HOST and PORT from command line, Default.\n *\t-h,--help\tPrint this help message.\n *\t-a\tPrint all message incomming from the client or outcomming to the server with verbous information.\n *\t--debug\tLaunch program in debug mod with pygdb.\n\nExample:\n========\n\t$ ./PyRlwrap.py ./IRCserver.py naereen-corp.crans.org 9312 -a\n\nCopyrigths:\n===========\n (c) 09/2012\n By Lilian BESSON\n ENS de Cachan (M1 Mathematics & M1 Computer Science MPRI)\n mailto:lbesson@ens-cachan.fr\n \n For Naereen Corp.\n mailto:naereen-corporation@laposte.net\n https:sites.google.com/site/naereencorp/liste-des-projets/irc.\n"

Help message for this program or this module (Keep in mind that it’s mainly designed to be a program, called from the command line)

IRCserver.main(args, HOST='127.0.0.1', PORT=2048)[source]

Create a socket on an host=args[1] with port=int(args[2]), and run a client on it.

IRCserver.kwargs = {'window-icon': 'server', 'title': 'IRC server'}

Args for all Zenity call

IRCserver.ask_arg(HOST, PORT)[source]

Use PyZenity to ask interactivly the arguments of the program.

IRCserver.AsZenity = False

Here disabled

Table Of Contents

Previous topic

IRCclient Module

Next topic

Bonus Module

This Page