Integrating chat tagging with $(touser)

I am creating some custom Nightbot commands used to answer frequently asked questions in chat.
Example command: !addcom !FAQ Here is the response to your question @$(touser)

I’d like to overload the command such that:

  1. you may type the command by itself and get a non-tagged response (ie !FAQ)
    (reply from Nightbot would be: Here is the response to your question.
  2. you may type the command with a username to tag the response for the specified username (ie !FAQ Muhalo)
    (reply from Nightbot would be: Here is the response to your question @Muhalo.

I understand the behavior of the $(touser) variable is to default to the command issuer if there is no parameter.
This is not ideal as it will appear the command issuer is somehow answering their own question.
I also know I cannot use $(1) or $(query) in this case, as they return undefined and none respectively.

Does there exist a variable that returns null if the parameter is not supplied?
Or, in this specific case, is there a way to suppress a chat tag variable if there is no parameter passed to it?
Thank you.

This would have to be done with a customapi that would take in $(1).
If $(1) is undefined or none of the FAQ options return the main non-tagged response.
Else if return the text matching the FAQ tag.

A simple PHP script would probably suit you well. Hope this helps.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.