Open zytakeshi opened 5 years ago
I'll have a look at the issue and get back to you.
_Problem solved.
/WHMCS-AutoReply/run.sh
change
sleep TIME_BETWEEN_CHECKS
to
sleep $TIME_BETWEEN_CHECKS
But now it has become trickier because I ran into another problem, I've created a ticket named 'server' content 'server' to test it, it says 'Dropped response.’ But when I go see the ticket it's still being left there open with no reply.
Do you know any way to debug it?
Sleeping for 300/60 minutes..._
Check the cURL response for the query executed to send the ticket response, and please reply with the contents.
Hi, FlamesRunner. Sorry for newbie question but how can I get a response for the query?
Tried to work on this line but didn't succeed.
curl -b cookie.txt -s --data "token=$CSRF_TOKEN&message=Test reply&postreply=1&status=Answered&priority=Medium&flagto=nochange&deptid=nochange&returntolist=1&billingaction=0" "$WHMCS_URL/supporttickets.php?action=viewticket&id=$LATEST_TICKET_ID"
Thank you so much for helping me. But I've asked my friends on how can I echo a cURL response and they didn't know how either.
Thanks!
You need to first execute the query that authenticates you:
`#!/bin/bash
echo <<EOT
\ \ / / | | | \/ |/ / | \ \ /\ / /| |_| | |\/| | | _ \ \ V V / | | | | | | ) | _/_/ || ||| ||_|____/
EOT
source config.sh
while true; do
echo "Logging into WHMCS admin..."
curl -d "username=$USERNAME&password=$PASSWORD" $WHMCS_URL/dologin.php -c .tmp/cookie.txt -s
# Use the WHMCS cookies retrieved
echo "Getting support tickets..."
curl -b .tmp/cookie.txt "$WHMCS_URL/supporttickets.php" 2>/dev/null > .tmp/tickets.txt
# Retrieve the latest ticket ID and output
LATEST_TICKET_ID=$(php scripts/getLatestTicket.php)
echo "Latest ticket ID: $LATEST_TICKET_ID"
echo "Getting ticket contents..."
curl -b .tmp/cookie.txt "$WHMCS_URL/supporttickets.php?action=view&id=$LATEST_TICKET_ID" 2>/dev/null > .tmp/ticketcontents.txt
echo "Checking if the ticket contains the preset keywords..."
TICKET_CONTENTS=`cat .tmp/ticketcontents.txt`
REPLY=false
for i in $KEYWORDS; do
if [[ -z "$(echo $TICKET_CONTENTS | grep -e $i)" ]]; then
$REPLY=true
break
fi
done
if [ $REPLY == 'false' ];
then
echo "The ticket did not return any results. Will not do anything."
else
echo "The ticket matches a keyword - executing response system..."
CSRF_TOKEN=$(php scripts/getCSRFtoken.php)
curl -b cookie.txt --data "token=$CSRF_TOKEN&message=Test reply&postreply=1&status=Answered&priority=Medium&flagto=nochange&deptid=nochange&returntolist=1&billingaction=0" "$WHMCS_URL/supporttickets.php?action=viewticket&id=$LATEST_TICKET_ID"
echo "Dropped response."
fi
echo "========================================================="
echo ""
echo "Sleeping for $(expr $TIME_BETWEEN_CHECKS/60) minutes..."
sleep TIME_BETWEEN_CHECKS
done `
I've modified the script slightly and it should give you a response. Please respond with it.
In addition: Don't spend too much time on this, I plan on rewriting it in PHP entirely. Stay tuned for that.
I've modified the code, added -S and now it shows an error down below.
curl: (6) Could not resolve host: cookie.txt
Hello,
I've written a PHP-only version, and have pushed it -- it's in the "new/" directory from the root of the repository. Inside you'll find a few files; change the options in "config.php" and set up a cron job on "cron.php."
I've no access to a WHMCS installation to test it, so there may be bugs. Please let me know if you find any.
Andrew
Hi,
I've ran it and it says
PHP Parse error: syntax error, unexpected '==' (T_IS_EQUAL) in /replybot/cron.php on line 13
I think it would be more efficient if you can actually test it.
Lemme know if you need a test environment. I'll set up one for you, be aware I'm a newbie and set up is going to take some time though...
Thank you so much for updating, it will be a gamechanger if it works.
That'd be greatly appreciated. In terms of a test environment, I'm really only looking for a plain WHMCS installation that I can run this against.
And no worries -- I used to work a support job and having this would've been great for me as well :)
In any case, I've gone ahead and fixed the extra bracket that was causing the error you posted. Do have another try.
I tried many ways to fix the didn't get it to work.
PHP Warning: file_get_contents(/tmp/tickets.txt): failed to open stream: No such file or directory in /WHMCS-AutoReply/scripts/getLatestTicket.php on line 3
*the original path returns the same error, so it is not about the path in my opinion.
sleep: invalid time interval ‘TIME_BETWEEN_CHECKS’ I've tried removing spaces, adding '' but none of that works.
Thanks