Skip to content

SIML guidelines

Łukasz Domeradzki edited this page Sep 2, 2017 · 27 revisions

SIML guidelines

When writing SIML for our AI brain, it's a good idea to stick with some common guidelines and best practices to write clean, efficient and properly working code. Those guidelines are general tips that you should take into account when writing SIML.


If given <Pattern> is not expected to be called by user, it should be prefixed with {Name}_ of the <Concept>.

For example, instead of:

<Concept Name="_bob">
  <Model>
    <Pattern>GET_RANDOM_CAT</Pattern>
  </Model>
</Concept>

You can write:

<Concept Name="_bob">
  <Model>
    <Pattern>_bob_GET_RANDOM_CAT</Pattern>
  </Model>
</Concept>

Thanks to that we won't need to fight with potential conflicts if the same pattern is declared twice in two different files.


Make use of pattern-matching in <Pattern> when only a few words differ between invocations.

For example, instead of:

<Concept Name="_bob">
  <Model>
    <Pattern>WHO IS KALEITH</Pattern>
    <Pattern>WHO IS THIELAK</Pattern>
  </Model>
</Concept>

You can write:

<Concept Name="_bob">
  <Model>
    <Pattern>WHO IS (KALEITH|THIELAK)</Pattern>
  </Model>
</Concept>

At the same time you should still stick with multiple patterns if they're entirely different or they do not differ only by a few words. This approach makes it easier for us, humans, to read the code.


If you're targeting a Steam emoticon in <Pattern>, target proper colon.

A pattern such as:

<Concept Name="_bob">
  <Model>
    <Pattern>:awoo:</Pattern>
  </Model>
</Concept>

Will work only with literal :awoo: text, as in - user who isn't permitted to use the emoticon.

When actual emoticon is used, Steam network encodes standard : into ː. If you want to target emoticon usage, you should instead write:

<Concept Name="_bob">
  <Model>
    <Pattern>ːawooː</Pattern>
  </Model>
</Concept>

This can also be used to tell when given emoticon is actually executed by user, and not faked with text.

<Concept Name="_bob">
  <Model>
    <Pattern>:awoo:</Pattern>
    <Response>You don't own that emoticon, why you're trying to use it?</Response>
  </Model>

  <Model>
    <Pattern>ːawooː</Pattern>
    <Response>Wow, you actually bought that expensive emote? You're crazy!</Response>
  </Model>
</Concept>

Consider using chat targetting for <Late> responses

Responses generated by the <Late> tag are by default sent to the last chat source the user interacted through with the bot. This might not be appropriate, for example because user could ask for something that generated <Late> task in private, then write something on group chat - in this case <Late> response will arrive also on the group chat and not to the original private user message.

To help prevent this you can set a destination ID before the <Late> message in the usual source-id format:

<Concept Name="_2hulate">
  <Model>
    <Pattern>^2HUTARGET _</Pattern>
    <Response>
      <Bind Key="{Message}"><Match /></Bind>
      <Text>I'll send that message to the Touhou Giveaways chat in 2 seconds!</Text>
      <Late Second="2">steam-110338190878500888 <Text>{Message}</Text></Late>
    </Response>
  </Model>
</Concept>

Another, perhaps more complete and practical example would be:

<Concept Name="_2hulate">
  <Model>
    <Pattern>SEND ME PROPER LATE TASK</Pattern>
    <Response>
      <Bind Key="{LateSource}"><User Get="SourceID" /></Bind>
      <Text>I'll send you in 5 seconds a proper late task regardless of your last chat interaction!</Text>
      <Late Second="5"><Text>{LateSource}</Text> I'm proper late task, hooray!</Late>
    </Response>
  </Model>
</Concept>

Remember that to send a private message, the destination ID will be the targeted user's ID.

Clone this wiki locally