Posts tagged irc
Bad words list (458 words)
62Are you creating a new forum, IRC channel, or pretty much any kind of website where users can submit links and you need to control bad words?
Well I was in that situation a few days ago, and it took a very long time until I managed to find some resources, so here I'll try to post a bad words list that I'll keep on building on as I find more sources.
I won't post the bad words list as text, as some public might find it offensive. Instead I'll just post a link to a zip file with the badwords.
Download:
The zip file contains a plain text file with one word per line, and a MySQL file to populate a database with id, word, and replacement.
- Bad words list v. 2.0 - 3kb (43597 downloads)
Change log:
- Added more words to the list and improved the MySQL one. The list now contains 458 unique words, sorted in alphabetical order.
- Public release: v. 1.0 - A standard bad words list in a txt file, containing 252 words, plus an SQL script that populates a MySQL database with badwords and their respective "replacement" euphemism.
If you know of any good bad words list please comment its URL, so I can add them to this list!
Creating an IRC bot in PHP from scratch
7
I came across several articles about this topic, and I decided to take a look at it, combine them, and actually have the bot work.
The way this bot works is it will open up a server, join an IRC chat channel and post a message, going into idle status after that, waiting to receive a ping in response. If you don't want to wait, once the message is posted you can cancel page loading and enter the page again (Not reload it, since that would send the message again), and you would have the message posted.
A good use for this bot (Although not recommended because of the high traffic) would be to send messages to hundreds of different IRC channels, or to have the program refresh the page every minute or so and send a message to certain IRC channels every x time.
We will create a new file, named "irc_bot.php" with the following function:
< ?php function writeIRC($msg){ // define your variables $host = "irc.dal.net"; $port=6666; $nick="demoTester"; $ident="DemoTester"; $chan="#frih"; $readbuffer=""; $realname = "Demo Tester"; // open a socket connection to the IRC server $fp = fsockopen($host, $port, $erno, $errstr, 30); // print the error if ther eis no connection if (!$fp) { echo $errstr." (".$errno.")\n"; } else { // write data through the socket to join the channel fwrite($fp, "NICK ".$nick."\r\n"); fwrite($fp, "USER ".$ident." ".$host." bla :".$realname."\r\n"); fwrite($fp, "JOIN :".$chan."\r\n"); // write data through the socket to print text to the channel fwrite($fp, "PRIVMSG ".$chan." :$msg\r\n"); $timep = 0; //set up timer $timep = round(microtime(), 3); //start microtime // loop through each line to look for ping while (!feof($fp)) { $line = fgets($fp, 128); echo $line."\n"; $line = explode(":ping ", $line); echo $line[0]."\n"; if ($line[1]) { fwrite($fp, "PONG ".$line[1]."\r\n"); } $time2 = round(microtime(), 3); //set up second timer $gen = $time2 - $timep; //find the difference if($gen > 30){ //timeout - break loop echo ' Operation finished without receiving ping. Check out the stats iframe to see your message. '; break; } } fclose($fp); } } ?>
Using it:
So now you should join a channel in the server you like, for this example I will be using one of frihost.com's IRC channels (Server: irc.dal.net Channel: #frih)
The way you would use this bot would be to send messages every set period of time for example, with loop functions, or to manage IRC channels, if you leave the last loop of code and you examine every single line posted on the channel.
You could also use it to warn users, or to post to several channels at the same time... The uses are varied, and here you have a base code to start from...
Have fun, and if you use it, post a link in the comments and I'll include it here in the article, as examples of usage.
Example of Bot working
Well I have created a simple page that will use POST to send data to the IRC server, and then I included the channel stats in an iframe below, so you can see the results live...
It's pretty cool, so try it, and if you wonder how it is done download the demo page.
For any questions/suggestions please comment