2

I have a IRC bot, how do I post multiple data to make this following text display on the main IRC channel "rock paper sizzor hand"?

Here is part of my script:

fwrite($ircSocket, "PRIVMSG " . $ircChannel . " :" . $msg . "\n");

As you can see $msg will grab "rock" how do I make the following code display and post paper, sizzor and hand?

EDIT:

Here is what I need:

<html><body>
<h4>IRC Bot Tester</h4>
<form action="irc.php" method="post"> 
Command: <input type="text" name="msg" />
Paper: <input type="text" name="paper" />
Sizzor: <input type="text" name="sizzor" />
Hand: <input type="text" name="hand" />
<input type="submit" />

<?php

$ircServer = "irc.underworld.no";
$ircPort = "6667";
$ircChannel = "#bots";

set_time_limit(0);

$msg = $_POST['msg'];
$paper = $_POST['paper'];
$sizzor = $_POST['sizzor'];
$hand = $_POST['hand'];

How do I get those $paper, $sizzor, $hand into the PRIVMSG Part. Whatever is entered into paper sizzor and hand has to have a space inbetween when posted onto the IRC main channel.

 fwrite($ircSocket, "PRIVMSG " . $ircChannel . " :" . $msg . "\n");

hakre
  • 193,403
  • 52
  • 435
  • 836
Ray
  • 341
  • 2
  • 6
  • 17
  • How are you getting `$msg`? This question borders on a dupe of http://stackoverflow.com/questions/4227518/php-irc-bot-not-sending-message-help . What was wrong with the previous answer? – Sean Bright Nov 19 '10 at 17:56
  • It looks like your code will post whatever the contents of $msg are to the channel. Can you show the code that sets the $msg variable ? I don't see the problem here, if you change $msg to be $msg = "paper" and call that fwrite it will post paper... – superfro Nov 19 '10 at 17:57
  • @Sean Sorry, Basically I have made a form which post "Command: " however I have Paper: and etc. How do I make it post on the PRIVMSG part? I basically need to insert paper near $msg on the code. – Ray Nov 19 '10 at 17:58
  • **next time be more descriptive about the title** – bcosca Nov 19 '10 at 18:53

2 Answers2

2

This will print whatever the values are in $msg, $paper, $sizzor, and $hand with a space in between each:

fwrite($ircSocket, "PRIVMSG $ircChannel :$msg $paper $sizzor $hand\n");

If you literally just want to output "rock paper sizzor hand" (It's scissor, BTW...) then you can just do:

fwrite($ircSocket, "PRIVMSG $ircChannel :rock paper sizzor hand\n");
Sean Bright
  • 118,630
  • 17
  • 138
  • 146
  • Sean, will that output on the main IRC channel: "rock paper sizzor hand" including the spaces? – Ray Nov 19 '10 at 18:06
  • Sean, The rock paper sizzor and hand may change depending on what the user enters. I was wonder if "fwrite($ircSocket, "PRIVMSG $ircChannel :$msg $paper $sizzor $hand\n");" would space out the out put. Please confirm. – Ray Nov 19 '10 at 18:17
0

Can you explain more clearly what you want?

It sounds as though you just want to display the string "rock paper sizzor hand" in which case

$msg = "rock paper sizzor hand";
fwrite($ircSocket, "PRIVMSG " . $ircChannel . " :" . $msg . "\n");

but I'm sure that's not what you want.

Surfrdan
  • 505
  • 3
  • 12