I'm trying to create a program, that when sent a private message is a chat pane, responds. I've figured out the logic to parse for private messages, but I've been having some trouble responding. Here's my code, and the HTMl for the form I'm trying to fill.
$mech->form_name("chatform"); $mech->set_fields( graf => '/msg stinkbank success' ); print $mech->current_form()->dump(); $mech->current_form()->click(); #$mech->click_button( value => "Chat");
<form name=chatform onSubmit='return false;'> <div id="InputForm" class=inputform> <Center> <input style="width: 70%;" maxlength=200 class=text type=text size=12 +name=graf onKeyUp='checkforenter(event);' autocomplete="off"> <input class=button type=button onClick="submitchat()" value="Chat"> </center> </div> </form>
The output from my dump is:
GET http://www7.kingdomofloathing.com/lchat.php [chatform] graf=/msg stinkbank success (text) <NONAME>=Chat (button)
So I know the field is being filled, but the message is not being displayed, which means submitchat() is not being called. When I comment out click() and use $mech->click_button() instead I get the following error: "Can't call method "header" on an undefined value at C:/Perl/lib/WWW/Mechanize.pm line 2381".
I guessing that click() isn't working because it searches for input of type 'submit' or maybe because clickevent is a function in the file not just making a request to server, but I don't know why I'm getting this error with click_button()
My goal is obviously to make submitchat() run while my msg is in the text field. What am I doing wrong? How can I accomplish this?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |