Skip to content

Functions Reference

Rob Ellis edited this page Dec 27, 2016 · 3 revisions

Back to Plugins and Functions


Functions

Topic functions

^respond(<topic_name>)

The ^respond("topic_name") function is used in the reply it takes the current input and check it against the selected topic more matches. Once it gets to the end of the topic it will unwind its way back and continue checking in the normal path.

> topic random

  + * i *
  - ^respond("i_topic")

  + * you *
  - ^respond("you_topic")

< topic

> topic i_topic

  + i am not *
  - No, you aren’t!

  + i am *1
  - Yes, you are!

< topic

> topic you_topic

  + you are not *
  - No, I am not!

  + you are *1
  - Yes, I am!

< topic

When the user says I am not a robot! the system will match it with the * i * rule and look first for a reply in gambits in the i_topic topic

^topicRedirect("topic_name","trigger")

^topicRedirect("topic","trigger") is used in the reply and is very similar to reply redirects except they redirect you to a reply in a specific topic.

> topic random

  + say something random
  - ^topicRedirect("something_random","__say__")

< topic

> topic something_random

  + __say__
  - Wind on the face is not good for you.
  - I watched Mr. Dressup as a kid.

< topic

Since the trigger is just like any other match, we use a double underbar to indicate it is special. This notation is not required in your scripts.

User facts functions

^save("key","value")

Saves a user variable, let's say the first name:

+ [my name is] *1
- Hello <cap>! ^save("firstName",<cap>)

^get(key)

Returns a saved user variable. If in the previous example the user said My name is Rob and the bot defined a user variable firstName with the value Rob, then this example will recall it and the bot will reply Hello Rob. Nice to see you again!

+ hello *
- Hello ^get("firstName"). Nice to see you again!

Time.js plugin

Warning Additional details & examples needed.

^getSeason()

Returns season (spring, summer, fall, winter)

^getDate()

Returns date 3, January 2015

^getDateTomorrow()

Returns tommorrow's date (4, January 2015)

^getTime()

Returns The time is 9:00

^getTimeOfDay()

Returns morning, afternoon or night

^getDayOfWeek()

Returns day of week (Monday, Tuesday)

^getMonth()

Returns month (January)

[WARNING - THIS HAS BEEN REMOVED IN V1] Math.js plugin

Allows performing various math functions

^evaluateExpression(parameter)

Returns I think it is (answer) or What do I look like, a computer? if not valid.

^numToRoman(parameter)

Returns I think it is (the roman number)

^numToHex(parameter)

Returns I think it is (hex equivalent)

^numToBinary(parameter)

Returns I think it is (binary equivalent)

^numMissing(parameters)

Returns I think it is (number) for a trigger like What number is missing from 1, 3, 5, 7

^numSequence(parameters)

Returns "I think it is N" to find a number missing from an arithmetic or geometric sequence

Warning Additional details & examples needed.


Back to Plugins and Functions