Skip to main content

Function bool_symb() in expressions

bool_symb() - the string function allows you to create messages with dynamically changing content. The choice of content depends on Conditions used.

The method of presenting information in this manual assumes that you have already familiarized yourself with the documents indicated by the links and, in general, understand the principles of the described functionality.


❖ Required functionality


Additional variables.
To connect, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Variables

Button macros and expressions.
To connect, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Buttons

Conditions.
To connect, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Buttons

Package of additional "Tokens of Functions".
To connect, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Actions

IMPORTANT: The purchase of functionality for the bot is available only to the Creator (owner) of the bot. Admins CANNOT buy functionality!


How to show different emoji depending on the time of day.

Your support service cannot work around the clock and you want to show users that it is night for you now and they need to wait for an answer longer than usual - until morning and the working day start.

TASK : To display the 🌞 icon during the day and the 🌒 icon at night in the message. Let's say the day starts at 8 am and the night starts at 11:59 pm.

Let's use one of the functions for working with the Date and Time dt_left() and the Date macros %date%:
dt_left("%date% 08:00:00") == 0  ➨ 8 am has already came (there is no time left before it)
dt_left("%date% 23:59:00") > 0 ➨ 12 am has NOT come yet (there is time left before it)

The final Expression will look like this:

{bool_symb(((dt_left("%date% 08:00:00") == 0) and (dt_left("%date% 23:59:00") > 0)),"🌞 It is Day" ,"🌒 It is Night")}


How to show different emoji in  the Morning, Afternoon and Evening.

TASK : Name the current period of the day in the message, taking into account the time zone of the bot.

Morning - from 00:00 to 12:00
{bool_symb(dt_diff("%date% 12:00:00", dt_now_tz()) > 0, "Good morning", "")}

Day - from 12:00 to 20:00
{bool_symb((dt_diff("%date% 12:00:00", dt_now_tz()) <= 0) and (dt_diff("%date% 20:00:00", dt_now_tz()) > 0), "Good afternoon", "")}

Evening - from 20:00 to 00:00
{bool_symb(dt_diff("%date% 20:00:00", dt_now_tz()) <= 0, "Good evening", "")}

If you place these three expressions in one message, then only one of them will be shown at the time.


How to show the amount of something using emoji.

In your game, the user can receive awards and you would like to graphically show the number of character awarded using emoji 🎖.

TASK : Show the 🎖 icons in the message in an amount equal to the number in the %reward% variable, and if there are no rewards, show the corresponding message. Let's say the number of rewards and the value in the %reward% variable is 3, the maximum number of rewards is 5.

Let's use a function int_symb() from the Expressions manual.

The final expression will look like this:

{bool_symb(%reward%, int_symb(%reward%, "🎖", 5), "You don't have rewards...")}

Result: 🎖🎖🎖


How to show the current and remaining to the maximum amount of something using emoji.

In your game, the character has health points and you would like to graphically show the amount of character health using emoji, as well as the current amount of damage of the character.

TASK : Show in the message 💚 icons in amount equal to the number in the %hp% variable, as well as 💔 icons in amount not reaching the maximum in case of damage and a corresponding message if there are no health points left at all. Let's say the current number of health points and the value in the %hp% variable is 7, the maximum number of health points is 10.

The final expression will look like this:

{bool_symb(%hp%, int_symb(%hp%, "💚", 10), "Your character is unconscious...\n")}{bool_symb((%hp% <= 10), int_symb((10 - %hp%), "💔", 10), "")}

The: symbol \n is a line break character.

Result (if health is 7):
💚💚💚💚💚💚💚💔💔💔
Result (if health is 0 (zero)):
Character is unconscious...
💔💔💔💔💔💔💔💔💔💔