Chat 2 by Siropu

Chat 2 by Siropu [Paid] 2.3.4

No permission to buy (€29.99)
See the above link in the previous post for the 1.5 version, however if you want a suggestion, I recommend installing XF2. It (XF) works so much better with mobile devices as well as new browser features - I waited a year to upgrade from XF 1.x but it was completely worth it.
Maybe after a while. It would be a big overhaul for us.
 
Hello,
I am looking to add a command to create a macro :
ex : /register command will display the message in the chat : "register an account to post your question"
What would be the options to parse in the command panel ?
Thanks
 
What is the use for the option Display:Custom?
I'm trying to disable the chat box on specific page(s). Is there a way to do that?
 
What would be the options to parse in the command panel ?
In src/Addons/Siropu/Chat/Command on your server create a new PHP file called Register.php and paste the following code in it:
PHP:
<?php

namespace Siropu\Chat\Command;

class Register
{
     public static function run(\XF\Mvc\Controller $controller, \Siropu\Chat\Entity\Command $command, $messageEntity, $input)
     {
          $messageEntity->message_text = \XF::phrase('the_phrase');
     }
}

In ACP > Chat > Commands create a new command named register with Execute callback options:
Siropu\Chat\Command\Register
run

Change the phrase to whatever in the PHP file.

What is the use for the option Display:Custom?
It allows you to place the Chat in a position other than the predefined positions. If you set that option, you can edit the Chat widget and set the position you want. If you do that, make sure that the user group permission that allows you to change display mode from the chat user settings is unset.

I'm trying to disable the chat box on specific page(s).
It depends on the page and can be done by modifying the Chat widget PHP file.

If I buy it can I install it in test environment (subdomain) and then in live?
Yes.
 
Hello @Siropu,
Thank you for your Help
In ACP > Chat > Commands create a new command named register with Execute callback options:
Siropu\Chat\Command\Register
run

Change the phrase to whatever in the PHP file.

When trying to save the new Command, i am facing this error message :

  • ErrorException: Fatal Error: Namespace declaration statement has to be the very first statement or after any declare call in the script
  • src/addons/Siropu/Chat/Command/Register.php:5

  • Generated by: kankan
  • Feb 14, 2019 at 11:37 AM
Stack trace

#0 [internal function]: XF::handleFatalError()
#1 {main}




Request state



array(4) {
["url"] => string(36) "/forums/admin.php?chat/commands/save"
["referrer"] => string(74) "https://www.forum-des-portables-asus.fr/forums/admin.php?chat/commands/add"
["_GET"] => array(1) {
["chat/commands/save"] => string(0) ""
}
["_POST"] => array(12) {
["command_name"] => string(9) "register"
["command_description"] => string(75) "Macro invitant l'utilisateur à créer un compte pour poster sur les forums"
["command_callback_class"] => string(29) " Siropu\Chat\Command\Register"
["command_callback_method"] => string(3) "run"
["command_rooms"] => array(2) {
[0] => string(1) "1"
[1] => string(1) "5"
}
["command_user_groups"] => array(2) {
[0] => string(1) "3"
[1] => string(1) "4"
}
["command_options_template"] => string(0) ""
["command_enabled"] => string(1) "1"
["_xfToken"] => string(8) "****"
["_xfRequestUri"] => string(35) "/forums/admin.php?chat/commands/add"
["_xfWithData"] => string(1) "1"
["_xfResponseType"] => string(4) "json"
}
}
 
Try this instead of the phrase: '[URL=' . $controller->buildLink('register') . ']' . \XF::phrase('the_phrase') . '[/URL]';
 
I tested :

Code:
<?php

namespace Siropu\Chat\Command;

class Register
{
     public static function run(\XF\Mvc\Controller $controller, \Siropu\Chat\Entity\Command $command, $messageEntity, $input)
     {
          $messageEntity->message_text = '[URL=' . $controller->buildLink('register') . ']' . \XF::phrase('http://www.google.fr test') . '[/URL]';
     }
}
But the text remains plain.
 
Replace 'register' with 'canonical:register'
BTW, the URL will link to the register page. If you want to use a custom URL, you can replace this part: ' . $controller->buildLink('register') . ' with the actual URL.
 
Thank you Siropu.
In facts i want to insert text and urls in the phrase.
The actuel rendering links also the txt:
ex :
195634
Any way to make test not linked ?
 
Just found the solution :

Code:
          $messageEntity->message_text = '[URL=' . $controller->buildLink('canonical:register') . ']' . \XF::phrase('http://www.google.fr') . '[/URL]'. \XF::phrase(' test') ;

Thank you for your kind support.
 
Just found the solution
\XF::phrase() is for xenforo phrases. If you are not using valid phrases, don't use that code.
Example:
$messageEntity->message_text = '[URL=' . $controller->buildLink('canonical:register') . ']http://www.google.fr[/URL]' . ' test';
 
Well not exactly
I want the user to be redirected to the thread creation url.
And the code leads him to the registration process.
How can i link to
Code:
/forums/-/create-thread
 
This part: $controller->buildLink('canonical:register') is the redirect link so instead use: $controller->buildLink('canonical:forums/-/create-thread')
 
Top Bottom