This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
programming:irc [2021/06/02 06:34] nanodano |
programming:irc [2022/03/13 16:49] (current) nanodano |
||
---|---|---|---|
Line 3: | Line 3: | ||
IRC stands for Internet Relay Chat. | IRC stands for Internet Relay Chat. | ||
- | ===== DevDungeon IRC Server ===== | ||
- | If you're looking for an existing server | + | ===== 2-minute Intro to IRC ===== |
- | <code> | + | <html> |
- | irc.devdungeon.com | + | < |
- | 192.53.170.182 | + | <iframe width=" |
- | </code> | + | </ |
+ | </html> | ||
- | ===== Clients | + | ===== Using IRC with netcat |
- | There are many clients out there, but here are a few: | + | < |
- | + | < | |
- | * [[http://xchat.org/ | + | <iframe width=" |
- | * [[https://pidgin.im/|Pidgin]] (GUI) - For Windows, download and install from the website. For Debian, install with '' | + | </center> |
- | * [[https://irssi.org/ | + | </html> |
- | ==== Basics ==== | + | ===== Basics |
- | Commands start with a ''/'' | + | Once you are connected to an IRC server like '' |
+ | Commands start with a ''/'' | ||
* ''/ | * ''/ | ||
Line 31: | Line 32: | ||
* ''/ | * ''/ | ||
- | Tag someone by starting the message with their username and a colon. This will usually ping their client and is similar to tagging someone. | + | Other commands: |
- | + | ||
- | < | + | |
- | nanodano: hey! | + | |
- | </ | + | |
- | + | ||
- | ==== Other commands | + | |
* ''/ | * ''/ | ||
Line 45: | Line 40: | ||
+ | |||
+ | ===== Clients ===== | ||
+ | |||
+ | There are many clients out there, but here are a few: | ||
+ | |||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[other: | ||
+ | * netcat - You can use netcat as a client if you understand the IRC protocol. Check out my video tutorial [[https:// | ||
+ | |||
+ | |||
+ | ===== Node.js Bot ===== | ||
+ | |||
+ | <code javascript simple_irc_bot.js> | ||
+ | var net = require(' | ||
+ | |||
+ | var BOT_NAME = ' | ||
+ | var BOT_CHANNEL = '# | ||
+ | |||
+ | var client = new net.Socket(); | ||
+ | |||
+ | client.connect(6667, | ||
+ | client.write(' | ||
+ | client.write(' | ||
+ | |||
+ | setTimeout(function(){ | ||
+ | client.write(' | ||
+ | client.write(' | ||
+ | }, 3000); | ||
+ | |||
+ | }); | ||
+ | |||
+ | client.on(' | ||
+ | console.log(' | ||
+ | var text = data.toString(); | ||
+ | var splitText = text.split(' | ||
+ | // If data starts with PING, respond with PONG :whatever | ||
+ | if (text.startsWith(' | ||
+ | client.write(' | ||
+ | console.log(' | ||
+ | } else if (splitText[1] == ' | ||
+ | // If data comes from a channel (#general): | ||
+ | // : | ||
+ | // If data comes from privmsg (dano): | ||
+ | // : | ||
+ | console.log(' | ||
+ | // Was it a direct message or to the channel? | ||
+ | if (splitText[2] == BOT_CHANNEL) { | ||
+ | | ||
+ | } | ||
+ | if (splitText[2] == BOT_NAME) { | ||
+ | | ||
+ | } | ||
+ | // Was the message a command? | ||
+ | if (splitText[3].substring(1).startsWith(' | ||
+ | console.log(' | ||
+ | // Cut off first character, and check command. Run appropriate function. !bitcoin. !ping !8-ball | ||
+ | var command = splitText[3].substring(2).trim().toLowerCase(); | ||
+ | console.log(' | ||
+ | if (command == ' | ||
+ | console.log(' | ||
+ | client.write(' | ||
+ | } | ||
+ | } | ||
+ | console.log(' | ||
+ | } else { | ||
+ | console.log(' | ||
+ | } | ||
+ | |||
+ | }); | ||
+ | </ | ||