Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Communications > Chat

    muirc 1.0

    Download button

    No screenshots available
    Downloads: 200  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Gawen Arab | More programs
    MIT/X Consortium Lic... / FREE
    January 19th, 2012, 13:22 GMT
    ROOT / Communications / Chat

     Read user reviews (0)  Refer to a friend  Subscribe

    muirc description

    Micro IRC Python client

    muirc is a minimalist and efficient Python module to create and parse IRC messages. It does the job, and only the job, in a Pythonic way.

    Parse & create IRC messages

    The module's name is muirc.

    import muirc

    The main function is transform, which can either parse a raw IRC message and returns an dictionary whose keys are the fields of the message ...

    >>> muirc.translate("PRIVMSG #irc :Hello, World! :-)\r\n")
    {'nick': None, 'host': None, 'command': 'PRIVMSG', 'user': None, 'params': ['#irc', 'Hello, World! :-)']}


    ... or parse a dictionary with IRC message's fields and returns a raw IRC message.

    >>> muirc.translate({'nick': None, 'host': None, 'command': 'PRIVMSG', 'user': None, 'params': ['#irc', 'Hello, World! :-)']})
    'PRIVMSG #irc :Hello, World! :-)\r\n'


    Applying transform twice returns the same object

    >>> muirc.translate(muirc.translate("PRIVMSG #irc :Hello, World! :-)\r\n"))
    'PRIVMSG #irc :Hello, World! :-)\r\n'

    >>> muirc.translate(muirc.translate({'nick': None, 'host': None, 'command': 'PRIVMSG', 'user': None, 'params': ['#irc', 'Hello, World! :-)']}))
    {'nick': None, 'host': None, 'command': 'PRIVMSG', 'user': None, 'params': ['#irc', 'Hello, World! :-)']}


    Some more advance example

    >>> muirc.translate(":nick!user@host PRIVMSG #irc :Hello, World! :-)")
    {'nick': 'nick', 'host': 'host', 'command': 'PRIVMSG', 'user': 'user', 'params': ['#irc', 'Hello, World! :-)']}

    >>> muirc.translate(muirc.translate(":nick!user@host PRIVMSG #irc :Hello, World! :-)"))
    ':nick!user@host PRIVMSG #irc :Hello, World! :-)\r\n'


    Connect to IRC server

    A Connection class is provided to interact with an IRC node. It can be used either to build a IRC client or server.

    Create a connection giving a 2-tuple (host, port).

    >>> conn = muirc.Connection(("irc.freenode.net", 6667))

    Proxy methods are provided to easily send IRC messages. The case is not important.

    >>> conn.nick("muirc")
    >>> conn.UsEr("a", "a", "a", "a")


    This class provides an iterator interface which yields a parsed object every time a IRC message is received. This option provides an easy&pythonic way to create an simple IRC way.

    The following example connects to FreeNode, join #muirc and send a hello world message.

    >>> state = "wait_motd"
    >>> for message in conn:
    ... if state == "wait_motd":
    ... # 376 => MOTD ends
    ... if message["command"] == "376":
    ... state = "end_motd"
    ...
    ... # Join #muirc
    ... if state == "end_motd":
    ... conn.join("#muirc")
    ... state = "wait_join"
    ...
    ... # Wait for join ack
    ... if state == "wait_join":
    ... if message["command"] == "JOIN":
    ... state = "hello_world"
    ...
    ... # Send "Hello, World! :-)" to the #muirc channel
    ... if state == "hello_world":
    ... conn.privmsg("#muirc", "Hello, World! :-)")
    ... state = "quit"
    ...
    ... # Quit
    ... if state == "quit":
    ... conn.quit("Bye, World! :-(")
    ... print "OK"
    ... break
    OK



    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    IRC client | chat client | IRC messages | Python | chat | IRC

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM