Internet Relay Chat

From XPUB & Lens-Based wiki
Revision as of 13:49, 20 April 2014 by Michael Murtaugh (talk | contribs) (→‎Programming an IRC bot in Python)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

wikipedia:Internet Relay Chat

Servers

As free software, anyone can download and run IRC server. In addition, there are many public IRC servers where you can create your own channels.

Public IRC: http://quakenet.org, http://freenode.net

Clients

IRC Clients

  • Pidgin

Browser Plugins

Web IRC Interfaces

  • [Kiwi IRC] a free javascript/web based IRC client
<Derp>   _____ _____ ______ _______   ________          __     _____ _______ 
<Derp>  |  __ \_   _|  ____|__   __| |___  /\ \        / /\   |  __ \__   __|
<Derp>  | |__) || | | |__     | |       / /  \ \  /\  / /  \  | |__) | | |   
<Derp>  |  ___/ | | |  __|    | |      / /    \ \/  \/ / /\ \ |  _  /  | |   
<Derp>  | |    _| |_| |____   | |     / /__    \  /\  / ____ \| | \ \  | |   
<Derp>  |_|   |_____|______|  |_|    /_____|    \/  \/_/    \_\_|  \_\ |_|   
<Derp>  __ ___ ___ ___   __          _  __ ___ 
<Derp>  )_) )  )_   )     / \  X  / /_) )_) )  
<Derp> /  _(_ (__  (     /_  \/ \/ / / / \ (   

<Derp> o--o  o-O-o o--o o-O-o     o---o o       o   O  o--o  o-O-o 
<Derp> |   |   |   |      |          /  |       |  / \ |   |   |   
<Derp> O--o    |   O-o    |        -O-  o   o   o o---oO-Oo    |   
<Derp> |       |   |      |        /     \ / \ /  |   ||  \    |   
<mennomarlon> ..
<Derp> o     o-O-o o--o   o       o---o   o   o   o   oo   o   o   
<source>

== Using in python ==

* [http://pypi.python.org/pypi/irc irc] library for python

=== Creating a bot in python ===
<source lang="python">
...

ASCII Art Inspirations

<joak> ok
<DerKaizer>                       o         _        _            _
<DerKaizer>            _o        /\_      _ \\o     (_)\__/o     (_)
<DerKaizer>          _< \_      _>(_)    (_)/<_       \_| \      _|/' \/
<DerKaizer>         (_)>(_)    (_)           (_)      (_)       (_)'  _\o_
<Derp>  ▄██████████████▄▐█▄▄▄▄█▌
<Derp> ██████▌▄▌▄▐▐▌███▌▀▀██▀▀
<Derp> ████▄█▌▄▌▄▐▐▌▀███▄▄█▌
<Derp> ▄▄▄▄▄██████████████▀
+------------------------------------------------------------------------------------+
|.........lolollccllllllcccccc::;;;;;;:cclc:::::::::::::::::::::::::ccccccccccccccccl|
|.........lolool,...'',;:cccllcccc::;,'..''''',,;:::::::::::::::::cccccccccccccccllll|
|.........lolool,............',;;,''........... ...';::::::::::ccccccccccccccclllllll|
|.........looooo;......................................',;:::ccccccccccccccllllllllll|
|........'loodoo;......................................  .;:cccccccccccclllllllllllll|
|........'ododdo;........................'''..............,;:cccccccccclllcccccccccc:|
|........'ododdo;....................''.',;'............. ..'';:cccccllccc:;:ccccccc:|
|........'ododdd;..................'''',;:c:,.....',;;,.........;ccllccc:ccc:ccccllll|
|........'oddddd;.................''',,;:cc:,',:::ccc:;,'.......';cclccc::looodoooddd|
|........,dddxdd;.............''.',,,;;;:clc:;cddxxxxxxl;'... ..,:cllccc:;loddddddddd|
|........,dxdxxd:......... ..'''.',::cldxxxxdld00KK00Od:;:;''..',:clcccc:;ldddooooooo|
|........,dxdxxd:...... ...,,'''';cloddxxkkkOOk0KKK0Oxxdddolc;;:;:cllccc::ldoolodooll|
|........;xxxxxx:'..... ..;;,''',coodxxxxkkOO0K00KKKKKK0OOkdc;,,,,:llccc::lddoloxxl'.|
|........;xxxxxx:.....  .;;,,''':oddxxxxxkkOO00KKKKKKKKK0Oxo;,'...':llcc::oddoldxko..|
|........;xxxkxx:....  .,;;;''.,ldxxxxddxxkOOO0000KKKK000ko:,''....,clcc::odddodkko..|
|........;xxxkxx:....  .;;;;''.;clooddoodddxkkO0000KKK000Oo,'......,llcc::odddodkkl..|
|........:xxxkkx:...   .,,'....'';;:lddooc::ccccldxk000000k:'..',..clllc::odddodkko..|
|........:xkxkkx:.'..  .'''......',,;lxkkdlc:;;,,;:ldkO0000d,..cxocllllc:cddddodkkl..|
|........:xkxkkx:....  .;;'','',,;;;;cdO0Okxocc::cloodk0K00x:,'lddollllc:cddddoxkkl..|
|........:kkkkkk:......';:::cccccc::;:oO000OOkxdxkO0KXXKKK0Ooc::oxollllc:cddddoxkkl..|
|........:kkkkkk:.'....':::clooooc::;:ok00KK00OOO000KKXKKK00xol:cdollllc:cddddoxkkc..|
|........:kkkkkk:.'.....;:cllooolc:;;cdk0000OkkOOO00KKKKKK0Okdoclclolllc:cdxddoxkkc..|
|........:kkkkkk:.'.....,::cllllc:;;:ldkK0000xdodxkO0KKKKK00kxdlcclolllc:cdxddoxkkc..|
|........:kkkOkk;.''....'::cccc::;;,,cloxxxkOOkxlcldkO00K000kdl:cloolllc:ldxddoxkk:..|
|........:kkkOkk:.''..'..;::::;::;,,',;:ldxxxxxxxoc;ldk00000oc::loooollc:ldxddoxOk:..|
|........:kkkkkk:.''..'..,::c;'',,,,,;clolodxxkxolocodkO000xlcclooooollc:ldxddoxxdlll|
|........:kkkOkk;..'.....';:c:;;,,',,;::clllooddxOkxOOOO00koooooooooollc:lxxxdddddddd|
|........ckkkOkk;...'.....';:clc::,,,;:clodxkO000OOkOOOOOkoooooooooooll::lxxxxxxxxxxx|
|........ckkkOkk,...'.....'',;:::::;;:cclodxO0000OOOOOOOOxlooooooooooll::lxxxxxxxxxxx|
|........ckkkOkk,.........'..',;::::cllodxxkOO000OOOkOkO0dlloooooooolll::lxxxdddddddd|
|........ckkkOkx,.............'',;:cclodxkOO0000OxddxkO00dlloooooooolll::lxxdooxxdddd|
|........ckkkOkk'................',;clodxdxkOkxxoc::dO000o:looooooollll::ldxdddkkkddd|
|........ckkkOkx'..............'....,:loollllc:;,,;lk00K00l';;;:llllllc::odxdddkkkxdd|
|........ckkkkkx' ...   ........''....'',,'''',,:oxO0000K0o.......',:::;;ldddodkkkxdx|
|........ckkkkkx.       ...... .',,,''',;;:clodkkOOO00000o'...............;cl::cloood|
|.... ...ckkkkkx.      ....    .',,;;;,,;:codxkkOO000Oxc,............... ............|
|:...  ..:l:;,,'.                ...',,,,;;clodddolc;'.................    ..........|
|;.     ..                                .............................     .........|
|'.       .                                ...............  ...........     .... ....|
|.        .                              .................  ..... .....     ...     .|
|         ..   .              ..          ......................  ....      ...    . |
| .   ..  ..   . . .           ...         ....................    ... .    ...   .  |
+------------------------------------------------------------------------------------+
+------------------------------------------------------------+
|...............................................       ......|
|...........................................            .....|
|.......................,'.,,,'.'';;;l:'',,..           .....|
|..............  .....;,:dkk0K0OOdxOOOx:';''...         .....|
|............... .,xxOxk0KNNXNNNNXXNKK0kxllo,;..        .....|
|.........  ....'':odxx0KKXXNNWWNNNNNXXXXKkxk:...       .....|
|.........     ..':cdk0KKO0KXXNNNNNNNNNXKXKKKko.....     ....|
|...           .,'dlodkKXXK0KXNNNNNNNNXXK0kk0N0d;..      ....|
|.             ..okoldxkO000OKKKKKX0K00kkkkcok0Ok;..      ...|
|            ..':ol:dxxkkO0OkxOO000doodddodl;xOxxxl:.      ..|
|          .'lx0dc;;:oxxxolc:clddoc;;:ccl:c:,;lO0dko,.      .|
|          ::O00xd:cldoc;,,,;:ccc;,'',;;;;;;;,:OOccd;.      .|
|          ..O0kl:;llcc:,'',,,,'''''',,,;;:,.':ok,;oc'.     .|
|        .  .kkxc.'ccc:;;'...........,;cc::,..,okkko,..     .|
|        .. ,k0kl..;::;;,,.........';;;:::lc. 'oOO0k'..      |
|          .ox0x' .llXXXdxo:'.....';lXXXc;',' .x00OO:,.      |
|          'dxKl .clcXXXX0KOd:...,lkxXXXold:,. ,OkkOkx.      |
|         ..l,;  ;lxxXXXclkxkd;.'c::lXXX:,::;.  kdxxl,;.     |
|         .;dc. .;;::;,,,;;cco;',:::;;;,''''''. oOxdd.       |
|         .'cl' .',;,,''',;:co:.';:;,''...'''.. ;ddld.       |
|          ..c.  .,,,'''.',:lo:'';c;'.....'''.. 'lkc:.       |
|           .d. .,;;;''...'cll:..';c'....''''....lOc.        |
|           ':c .,,;;,'...'lcOl''dd,,....''''...;c;,         |
|            .c. ';:;,'..''cocc:,;::'.....'''''.;,.          |
|                ':;;,',,,,,'..,...'''.....',,'.'..          |
|                .::;,,;;,,;;;;,,''..'''...','.              |
|                 ':;',';lLASSETHEBOSS0o;..''..              |
|                  .;''',:cllcc::::;,'......'.               |
|                   .'',,,;,''''.............                |
|                   ...,,,,,''............',.                |
|                   .:,.',,,''...........',,.                |
|                   .:c:,'',''......''''''''.                |
|                   .:::cc;,,,,,,,,,''''......               |
|                   .;;;:cc:;;,,,''''''........',.           |
|             '..   .,,,,;;;,,''''..............'            |
|             ..''..','..'','''...............''.            |
|            ...';::;,'....'....................       ......|
|              ...;c;,''......................          .....|
|                 ..,;::;'.................              ....|
|                     ..,;,,;:ccc:;,....                  ...|
|                                                           .|
|                                                           .|
+------------------------------------------------------------+

Programming an IRC bot in Python

Download this http://pypi.python.org/pypi/irc

#! /usr/bin/env python

"""
HelloBot
"""

import irc.bot
from time import sleep

class Bot (irc.bot.SingleServerIRCBot):
    def __init__(self, server, channel, nickname, port=6667):
        irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
        self.channel = channel

    def on_nicknameinuse(self, c, e):
        c.nick(c.get_nickname() + "_")

    def on_welcome(self, c, e):
        c.join(self.channel)

    def on_privmsg(self, c, e):
        sleep(2)
        c.privmsg(e.source.nick, "I don't speak privately")

    def on_pubmsg(self, c, e):
        msg = e.arguments[0]
        print msg
        sleep(2)
        c.privmsg(self.channel, "you said:" + msg)

#############################################
# Standard code to start the bot
#############################################

def main():
    import sys
    if not len(sys.argv) >= 3 :
        print "Usage: testbot server[:port] channel nickname"
        sys.exit(1)

    s = sys.argv[1].split(":", 1)
    server = s[0]
    if len(s) == 2:
        try:
            port = int(s[1])
        except ValueError:
            print "Error: Erroneous port."
            sys.exit(1)
    else:
        port = 6667

    channel = sys.argv[2]

    nickname = sys.argv[3]
    bot = Bot(server, channel, nickname, port)
    bot.start()

if __name__ == "__main__":
    main()

LInks