Manual:DIL Manual/dispatch()

From DikuMUD Wiki
Jump to navigation Jump to search

dispatch()

Procedure. Sends a line to programs outside the game, such as the Discord bot.

dispatch(s : string)

Writes s, as one line, to the named pipe pipeDispatcher in the game server's working directory (vme/bin). The program dispatcher.py there reads the pipe; the first word says where the line goes. The only destination it knows is discord: the rest of the line goes to the Discord bot (muddiscord.py), which understands msg #channel text (without a #channel the line goes to #mud) and who .... That is how bug and typo reports, the who list and the welcome of new players reach Discord.

Parameters

Name Type Meaning
s string The line to send, starting with its destination, e.g. "discord msg #bugs ...".

Notes

  • Nothing tells the program whether it worked. When no dispatcher is running, the line is lost and vme.log says "Unable to open pipe WO ./pipeDispatcher".
  • Any zone may use it, so a line can reach a public Discord channel from any script: use it only for what is meant to be public.
  • The game doesn't change the text. HTML entities (", &, <, >) are turned back into characters by dispatcher.py.
  • Lines from Discord come back the other way, through the pipe pipeMUD, to the DIL program dispatcher@comm.

Example

dilbegin cmd_typo(arg : string);
code
{
   if (length(getwords(arg)) < 2)
   {
      sendtext("Please describe the typo in a few words.<br/>", self);
      quit;
   }
   dispatch("discord msg #bugs @" + self.name + " TYPO report: " + arg);
   sendtext("Thank you, the report has been sent.<br/>", self);
   quit;
}
dilend

A typo command that sends the report to the #bugs channel on Discord, as in commands.zon.

See also