Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Torrent Trader (http://www.bvlist.com/forumdisplay.php?f=29)
-   -   Shout auto reply torrenttrader 2.06 (http://www.bvlist.com/showthread.php?t=6884)

CL_Utility 21st August 2011 08:57

Shout auto reply torrenttrader 2.06
 
Ive played around a bit and keep coming up with absolutely nothing, but has anyone seen or does anyone have a suggestion for where i might start this? basically what i want is a bot that picks up certain words put into shout by a user and gives predetermined responses

e.g

if i post in shout

User: hello

shout box would recognize the word "hello" and i would receive an automated response from bot

Bot: how are you


the problem is i dont know how to trigger it to even start

ive got a start on the response though

Code:

$query = "INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, 'Bot', 'how are you', '".get_date_time()."', '0')";
any help would be appreciated

joeroberts 21st August 2011 09:08

place this after the shout query
PHP Code:

if(strtolower($shout) == "hello")
{
$query "INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, 'Bot', 'how are you', '".get_date_time()."', '0')";
mysql_query($query);



CL_Utility 21st August 2011 09:38

(strtolower($shout) doesnt seem to be a valid variable l in TT shoutbox or if it is it is out of my range of limited knowledge lol and that is my main problem is i dont know what i should be calling.

but thankyou for ur help joe, this is all a learning experience for me, i am not running a site i just want to play :)

joeroberts 21st August 2011 09:45

Quote:

Originally Posted by CL_Utility (Post 29577)
(strtolower($shout) doesnt seem to be a valid variable l in TT shoutbox or if it is it is out of my range of limited knowledge lol and that is my main problem is i dont know what i should be calling.

but thankyou for ur help joe, this is all a learning experience for me, i am not running a site i just want to play :)

First off change
PHP Code:

$shout 

to what ever TT is using I just took a shot as to what it was
and
PHP Code:

strtolower() 

is php not torrent trader
It changes a text to all lower texts (HeLLo becomes hello)

CL_Utility 21st August 2011 09:50

thanks Joe! ive got it working now, im learning heaps. and i thank you eternally

would there be a way to make that pick up part of the statement? as in if i said "hello everybody" it still picked up "hello" and responded?

joeroberts 21st August 2011 11:36

yes by using
PHP Code:

if(preg_match("/hello (.*)/",strtolower($shout),$m)) 


CL_Utility 21st August 2011 12:39

what does the $m refer to? is that something i need to change?

joeroberts 21st August 2011 14:32

no the $m becomes an array with the content of (.*) in it

CL_Utility 22nd August 2011 09:11

ok so i changed $shout to $message as that is what TT is using, but that is not working

joeroberts 22nd August 2011 12:33

try this
PHP Code:

if(strtolower($message) == 'hello' OR preg_match("/hello (.*)/",strtolower($message),$m)) 



All times are GMT +2. The time now is 09:22.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.