Skip to content

General

Joshua Haas edited this page Feb 19, 2017 · 7 revisions

The general plug-in contains commands that don't fit in others. This includes commands to control the bot itself, as well as a few others.

Dependencies

  • cec-client - (OPTIONAL) HDMI CEC client for tv commands

Config

  • general.alias_depth - max stack depth when executing aliases (default 10)
  • general.alias_file - file to store aliases (default 'data/aliases.txt')
  • general.calc_degrees - use degrees instead of radians in the calc command
  • general.calc_scientific - always use scientific notation from the calc command
  • general.config_rooms - allow the config command in rooms (default True)
  • general.log_lines - number of lines to report in the log command (default 10)
  • general.log_time - if True, include timestamps in log command reports (default True)

Not all devices are CEC capable, although the Raspberry Pi notably is. This feature has only been tested on Linux. In order for the TV command to work correctly, cec-client must be available on sibyl's user's PATH, and sibyl's user must have access to the cec-adapater (e.g. vchiq) which can usually be achieved by adding sibyl's user to the video group.

Commands

  • alias: add aliases for cmds - alias (info|list|add|remove|show) [name] [cmd]
  • calc: perform basic math calculations
  • config: view and edit config - config (show|set|save|diff|reset) (opt|*) [value]
  • die: kill sibyl
  • echo: echo some text
  • log: set the log level - log (info|level|clear|tail|trace)
  • network: reply with some network info
  • reboot: restart sibyl
  • 'tv': pass command to cec-client - tv (on|standby|as)
  • ups: get latest UPS tracking status - sibyl ups number
  • wiki: return a link and brief from wikipedia - wiki title

alias

sibyl alias (info|list|add|remove|show) [name] [cmd]

This allows the creation of aliases that can be activated the same way as normal chat commands (e.g. sibyl myalias or !myalias). They can be used to execute commonly run commands or series of commands. Aliases cannot be named the same as any existing chat commands.

  • info - responds with the number of aliases in sibyl
  • list - list the names of all aliases
  • add name cmd - add an alias that responds to name and executes cmd
  • add name cmd1; cmd2; ... - as above, but multiple commands divided by semi-colons
  • remove name - delete the alias called name
  • show name - respond with the command text of the specified alias name

Perhaps you would rather call sibyl on instead of sibyl tv on:

sibyl alias add on tv on

How about we set it as the active source at the same time?

sibyl alias add on tv on; tv as

Chat arguments are passed to all commands in the alias:

human: sibyl alias add hi echo "Hello "
sibyl: Added alias "hi"
human: sibyl hi Bob
sibyl: Hello Bob

Aliases can even nest other aliases:

human: sibyl alias add one echo One!
sibyl: Added alias "one"
human: sibyl alias add two echo Two!
sibyl: Added alias "two"
human: sibyl alias add count one; two
sibyl: Added alias "count"
human: sibyl count
sibyl: One!
sibyl: Two!

Aliases are stored in the file specified by the general.alias_file config opt as a tab-delineated text file with one alias per line. Additionally, the general.alias_depth config opt controls the max number of "nests" (in other words, the max size of the stack) allowed in alias execution. This also breaks infinite alias loops after a set number of iterations. Finally, note that aliases respect the black/white list, so in the example above, let's say the user is black-listed from executing echo. Then when they tried to do sibyl count they would get You are not allowed to run "echo".


calc

available: $e, $pi, $time, cos, sin, tan, fact, int, log, log10

This command uses the python interpreter to do math. All of the basic operations are available (+, -, *, /, %, ^) as the functions listed below. Note that, by default, trig functions excpect and return degrees. To use radians set general.calc_degrees = False in your config.

function  example     description
------------------------------------------------------------
fact      fact(4)     factorial, i.e. fact(4) == fact(4)
int       int(2.5)    return the integer portion
log       log(1)      natural logarithm
log10     log(10)     base 10 logarithm
cos       cos(90)     cosine (trig)
sin       sin(180)    sine (trig)
tan       tan(45)     tangent (trig)
cos-1     cos-1(0)    inverse cosine (trig)
sin-1     sin-1(-1)   inverse sine (trig)
tan-1     tan-1(1)    inverse tangent (trig; range [-90,90])

You can also use the special constants $e, $pi, and $time. For example, sending calc log($e) will give you 1.0. The $time variable repesents the current time, in seconds since the epoch (Jan 1, 1970 on unix-like).


config

sibyl config (show|set|save|diff|reset|reload) (opt|*) [value]

This command is disabled by default. To enable it, set chat_ctrl to True.

Manages config options. This is a powerful command, and should almost always be blacklisted for everyone else. Note that some config options may not be modified via chat (protocols, disable, enable, rename, cmd_dir, rooms). You also can't access or modify any options that ends with password.

  • show * - returns a list of all config options (password is redacted)
  • show opt - returns the value of the specified opt
  • set opt value - set opt to be value (not saved to the config file)
  • save opt value - save opt to be value (is saved in the config file)
  • save * - save all options that have been modified with set to the config file
  • diff * - lists all options that have been set but not saved
  • diff opt - displays the current and previous value of opt
  • reset * - resets all options that were changed via set
  • reset opt - resets the specified option to before it was changed via set
  • reload opt - reload the specified option from the config file (i.e. file was edited outside of sibyl)

Please note that diff and reset do not work on options changed with save.


die

sibyl die

This command is disabled by default. To enable it, set chat_ctrl to True.

Kills sibyl using sys.exit(). Note that this does not clean up the PID file created by the init script.


echo

sibyl echo text

Sibyl responds with the entered text.


log

sibyl log (info|level|clear|tail|trace) [n] [regex]

This command is disabled by default. To enable it, set chat_ctrl to True.

This allows some basic debugging and log management from chat.

  • info - respond with some statistics about the log file
  • level - return the current log level
  • level name - set level to debug, info, warning, error, critical
  • clear - clear the log file
  • tail - respond with the last general.log_lines lines in the log file
  • tail n - respond with the last n lines
  • tail regex - respond with the last lines matching the given regex
  • tail n regex - combine the above two
  • trace - respond with the last traceback in the log (only works for debug level)

network

sibyl network

Responds with some basic network info. Could be helpful if you have dynamic DNS or a dynamic external IP address. The returned addresses are explained below:

  • My IP - the device running Sibyl
  • XBMC IP - the xbmc_ip option set in the config file
  • External IP - seen by the internet (uses http://ipecho.net/plain)

reboot

sibyl reboot

This command is disabled by default. To enable it, set chat_ctrl to True.

Reboot the bot from within python. Depends on logic in run.py to work.


tv

sibyl tv (pow|on|standby|as)

Can be used to control a connected HDMI television (does not work with all TVs). You can turn it on or off with on and standby. You can also switch the TV input to the HDMI connected to sibyl with as. The pow command returns whether the TV is currently on or off.

Please see the Dependencies section at the top of the page for additional info. Also note that you can get a list of commands by entering echo help | cec-client on the command line of the HDMI connected device. You can use any of the listed commands.

ups

sibyl ups tracking#

Return the most recent activity from the UPS website for the indicated tracking number.


wiki

sibyl wiki topic

Returns a link and brief from Wikipedia based on the search results for topic. The Wikipedia Open Search interface isn't always that nice, so YMMV.

Clone this wiki locally