|
| Author |
Message |
BradRobbo Newbie

Joined: 28 Nov 2003 Posts: 16
   
|
Posted: Fri Nov 28, 2003 8:44 pm Post subject: |
|
|
hi, i cant send smileys to my bot it just logs off 
ok heres wats on my command.com screen:
| Code: | | <br /><br /><br /><br />C:\DOCUME~1\OWNER>bot.pl<br /><br /><br />Including on_config.pl.. OK!<br />Including on_error.pl.. OK!<br />Including on_evil.pl.. OK!<br />Including on_im.pl.. OK!<br />Including addreply.pl.. OK!<br />Including docrypt.pl.. OK!<br />Including logoff.pl.. OK!<br />Including sendim.pl.. OK!<br />Including Backup of thought.pl.. OK!<br />Including commands.pl.. OK!<br />Including dosleep.pl.. OK!<br />Including log_im.pl.. OK!<br />Including replyhi.txt.. OK!<br />Including thought.pl.. OK!<br />Including warners.pl.. OK!<br /><br />Bot loaded successfully!<br /><br /><bradrobbo> hi<br /><bradleyno1> Hello!<br /><br />Sleeping for 1.28472900390625 seconds.. Done.<br /><br /><bradrobbo> bye<br /><bradleyno1> c ya later<br /><br /><br />Sleeping for 2.42669677734375 seconds.. Done.<br />############# here i put a;-) to the bot<br />Unmatched ) in regex; marked by <-- HERE in m/^:-) <-- HERE |:)|$/ at extras/tho<br />ught.pl line 30.<br /><br />C:\DOCUME~1\OWNER><br /> |
heres wot i have in my thought.pl
| Code: | | <br />sub thought {<br />my ($victim,$msg,$reply) = (shift,shift,"");<br />$msg = lc($msg);<br />if ($msg ne "") {<br /> if ($msg =~ /my name is/i || $msg =~ /name is/i) {<br /> $reply = "I don't feel it's important to remember names.";<br /> }<br /> else {<br /> #get data from the file<br /> open (FILE, "data.txt");<br /> my @data = <FILE>;<br /> close(FILE);<br /> <br /> #go through the data<br /> my $found = 0;<br /> foreach $item (@data) {<br /> if ($item ne "" && $found == 0) {<br /> my ($first,$last) = split(/\]\[/,$item); <br /> if ($msg =~ /^$first$/i) { ###line 30<br /> $msg =~ s/<(.|\n)+?>//g;<br /> $found = 1;<br /> @last = split(/\|/,$last);<br /> $reply = $last [ int(rand(scalar(@last))) ];<br /> }<br /> }<br /> }<br />}<br /> <br />#if we didn't find a response, say something<br /> if ($reply eq "") {<br /> ### THIS IS WHAT YOUR BOT SAYS WHEN IT DOESN'T FIND A RESPONSE ###<br /> $reply = "I don't know how to reply to that.. do you want to Teach Me? Type: <br>/addreply=$msg||<i>add-response-here...</i>";<br /> }<br />}<br />else {<br /> $reply = "Let's change the subject.";<br />}<br /><br />#Send back the response.<br />return $reply;<br />}<br />1;<br /><br /> |
|
|
| Back to top |
|
 |
BradRobbo Newbie

Joined: 28 Nov 2003 Posts: 16
   
|
Posted: Fri Nov 28, 2003 8:53 pm Post subject: |
|
|
*lazy* may also want to know that these are two lines in my data.txt
| Code: | | :-)|:)|][:-)|heh|hehe|hi<br />;)|;-)][heh|;)|why are you winking at me? :-P|;-) |
|
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Fri Nov 28, 2003 9:36 pm Post subject: |
|
|
Try escaping the punctuation in your data.txt file: the characters ":", "-", ")" all have meaning inside a regular expression.
| Code: | | \:\-\)|\:\)|][:-)|heh|hehe|hi<br />\;\)|\;\-\)][heh|;)|why are you winking at me? :-P|;-) |
That may or may not work - I forget how Perl deals with punctuation inside a string variable which is then used in a regular expression.
If it does work, you might want to do the escaping in your code rather than in the data.txt file, so your data doesn't look messy. |
|
| Back to top |
|
 |
eric256 The Keymaker

Joined: 03 May 2006 Posts: 2292 Location: Colorado
     
|
Posted: Mon Dec 01, 2003 4:14 pm Post subject: |
|
|
Perl does treat those characters as regex thats why you can use regex in the data file. If you want those to not be treated as regex then you would have to change the regex portion of the code. I don't know the changes off the top of my head but i could find them if you want to do it that way. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com |
|
| Back to top |
|
 |
Nate God Like

Joined: 12 Nov 2003 Posts: 553
    
|
Posted: Mon Dec 01, 2003 7:43 pm Post subject: |
|
|
I think it's like this, replace this line:
| Code: | | if ($msg =~ /^$first$/i) |
With this one:
| Code: | | if ($msg =~ /$first/i) |
I think that should do it. |
|
| Back to top |
|
 |
eric256 The Keymaker

Joined: 03 May 2006 Posts: 2292 Location: Colorado
     
|
Posted: Mon Dec 01, 2003 10:10 pm Post subject: |
|
|
No. The ^ at the begging and $ at the end tell it that the regex inbetween those should match all the way from the begging of the string to the end. That has nothing to do with wether it sees the var as having regex chars or not. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com |
|
| Back to top |
|
 |
|