Futurism › object › gate
From Botdom Documentation
The gate object acts as a gateway to the world outside; both input and output. It is utilized through both the Terminal and files.
Properties
- instance gate.log — The gate.log global object.
- str/bool gate.iom — The gate I/O manager; if this is False, there's no special effects such as colours in the Terminal (the "gate"), but if there is an I/O manager, this is a string representing it.
- str gate.path — The absolute path to the bot (directory seperators are always forward slashes).
Methods
tuple gate.formattime(int seconds)
Formats seconds input into different time units. Returns a tuple with (w, d, h, m, s) format.
t = gate.formattime(890) # t is: (0, 0, 0, 14, 50)
str gate.formattstr(int seconds)
Formats seconds input into different time units. Returns a str with X weeks, X days, X hours, X minutes, X seconds format, with zero-values omitted.
t = gate.formattstr(890) # t is: 14 minutes, 50 seconds
void gate.header(str title[, str sepchar])
Writes a header displaying the string title, to the gate. A header is always capitalized, and the character used in sepchar are repeated after the title, act as a seperator in the gate. sepchar is normally a hyphen symbol, "-". The width of the Terminal is assumed to be the standard; 80 characters. If the gate I/O manager is on, the header is attempted displayed as bold. A shortcut to this method is gate.hdr.
gate.header("Header title") # prints: [10:55:00] ** HEADER TITLE ---------------------------------------------------- gate.header("Header title", "oh ") # prints: [10:55:00] ** HEADER TITLE oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh o
void gate.message(str message[, bool ln])
Writes a message displaying the string message, to the gate. A message is prefixed with two asterisks (**) for visibility. The bool ln indicates whether a newline character should be printed after the message; this defaults to True. A shortcut to this method is gate.msg.
gate.message("This is a message!") # prints: [10:55:00] ** This is a message!
mixed gate.opendata(str name)
Opens a bot save file (BSV) with the inputted name as filename and returns the processed data contents.
d = gate.opendata("moduleconf") # opens file savedata/moduleconf.bsv # d is: {'internal': {}, 'dAmn': {}}
bool gate.savedata(str name, mixed data)
Processes (pickles) the inputted data and writes it to a bot save file with the inputted name as filename. Returns True upon success.
s = gate.savedata("moduleconf", {'internal': {}, 'dAmn': {}}) # saves in file savedata/moduleconf.bsv # s is: True
void gate.write(str message[, bool ln])
Writes the raw text message to the gate, prefixed by a timestamp. The bool ln indicates whether a newline character should be printed after the text; this defaults to True. All gate-writing methods passes their data through this method, and it is not recommended to use it directly. Use gate.message to write a message to the gate.
gate.write("raw text!") # prints: [10:55:00] raw text!
void gate.writel(str name, str subfolder, str message)
Writes the raw text message to both the gate using gate.write, and to a log file with the filename name in the subfolder subfolder (leave as empty string for none) using gate.log.write. For futher documentation, see these two methods.

