Note that there are some explanatory texts on larger screens.

plurals
  1. POIRC related help
    text
    copied!<p>Now I have my bot to send message when the bot joins. However how do I make a form that would post data so that the bot will say the message to the channel?</p> <p>Here is my script (Rewamped):</p> <pre><code>&lt;?php set_time_limit(0); $socket = fsockopen("//", 6667) or die(); $msg = $_POST['message']; $pr = $_POST['percentage']; $pr /= 100; fputs($socket,"USER BOT 0 zo :ZH bot\n"); // Set the bots nickname fputs($socket,"NICK BOT1\n"); fputs($socket,"JOIN #bots\n"); while(1) { while($data = fgets($socket, 128)) { // echo the data received to page echo nl2br($data); // flush old data, it isn't needed any longer. flush(); $ex = explode(' ', $data); if($ex[0] == "PING") fputs($socket, "PONG ".$ex[1]."\n"); $search_string = "/^:([A-Za-z0-9_\-]+)[@!~a-zA-Z0-9@\.\-]+\s*([A-Z]+)\s*[:]*([\#a-zA-Z0-9\-]+)*\s*[:]*([!\#\-\.A-Za-z0-9 ]+)*/"; $do = preg_match($search_string, $data, $matches); // check that there is a command received if(isset($matches['2'])) { switch($matches['2']) { case "PRIVMSG": $user = $matches['1']; $channel = $matches['3']; $chat_text = isset($matches['4']) ? $matches['4'] : ""; // check chat for !time if(strtolower($chat_text) == "!time") { $output = "::::: " . date('l jS \of F Y h:i:s A') . " :::::"; fputs($socket, "PRIVMSG " . $channel . " :" . $output . "\n"); } elseif(strtolower($chat_text) == "!hello") { fputs($socket, "PRIVMSG " . $channel . " :Hello!\n"); } break; case "JOIN": $user = $matches['1']; $channel = $matches['3']; fputs($socket, "PRIVMSG " . $channel . " :Welcome " . $user . " to " . $channel . "\n"); break; } } } } ?&gt; </code></pre> <p>E.g. Making a form that would send the data to the IRC channel. The output would be "wget file info port" &lt;-- That would be the text sent to the IRC channel.</p> <p>Here are parts related:</p> <pre><code>fputs($socket, "PRIVMSG " . $channel . " :Welcome " . $user . " to " . $channel ."\n"); </code></pre> <p>Hope someone can help out.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload