Setting can_send_commands flag in chat plugin from an alias

Posted by Bobble on Tue 27 Jan 2004 04:26 AM — 2 posts, 13,477 views.

Canada #0
Greets all,

I've encountered what I believe to be a small problem, but I can't seem to figure out how to solve it.

I'm just starting to use the chat plugin. I've created an alias in MUSHCLIENT (not by modifying the chat plugin itself) to turn on certain chat options, here it is:
<aliases>
  <alias
   match="chaton"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>SetAlphaOption &quot;chat_name&quot;, &quot;Bobble&quot;
SetOption &quot;accept_chat_connections&quot;, 1
chatcall &quot;1.1.1.1&quot;, 4050
SetChatOption (ChatGetID (&quot;Bill&quot;)), &quot;can_send_commands&quot;, 1</send>
  </alias>
</aliases>


Everything is working fine except for the very last option. I want this alias to set it up so that I accept commands (sent via the #command function) from Uvatha. What I've got here doesn't generate any errors, but it doesn't make it so that uvatha can send me any commands either. I get the "Bill attempted to send you a command." message.

All I'm looking for is a way to create an alias that sets it so that I can accept commands from Bill. What have I done wrong?

Also, RE the chat client, what exactly is in a Long ID. For instance if, instead of using getchatID, I just wanted to enter the ID manually, what info would I have to give it and what would it look like (by this I mean would it have brackets, quotes, etc around it.)

Thanks all
Amended on Fri 09 Jul 2004 06:54 PM by Bobble
Australia Forum Administrator #1
OK, I think I see. First I'll get rid of the &quot; things from your post, which are not really needed, although I know the XML writer generates them ...




SetAlphaOption "chat_name", "Lessik"
SetOption "accept_chat_connections", 1
chatcall "1.1.1.1", 4050
SetChatOption (ChatGetID ("Uvatha")), "can_send_commands", 1



So I gather what you are doing is calling someone on an address (1.1.1.1 in your example, although I presume that is not really it), and a moment later you are letting Uvatha send you commands.

However the documentation for "chatcall" states this:




Because of the asynchronous nature of TCP/IP a "good" status from this call does not necessarily mean you will establish a chat session, it just means it has succeeded in starting the process.

In order to establish a chat session, MUSHclient must:

  1. Look up the name using the Domain Name Server (DNS) unless a dotted-decimal name was given - this may take a few seconds.
  2. Connect to the chat server - this may take a few more seconds
  3. Attempt to negotiate a chat session by sending "CHAT:" to the chat server
  4. Await a response - this may take a while if the player at the other end is deciding whether to accept the connection or not.
  5. Finally, if all goes well, the chat session is established.



To know if the session was really established you need to use the plugin callback routine "OnPluginChatNewUser" - this notifies you when a new user is established.




The point here is that you are setting Uvatha as "can send commands" too soon, the connection would not yet be made.

What you need to do is add a "chat callback" to either the standard chat plugin, or make your own little plugin which has something like this in it:




sub OnPluginChatNewUser (id, name)

  Note "New chat user: " & name

  if LCase (name) = "uvatha" then
     SetChatOption id, "can_send_commands", 1
  end if

end sub




The standard chat plugin has a template for doing the above which is very similar to what I posted there.