Skip to content

Session Storage

Abdi Urgessa edited this page Nov 23, 2023 · 2 revisions

Sessions

within help of apps script, now telesun provide the easy way to work across sessions

Telesun provides 2 kinds of sessions :

  • Temporary Sessions
  • Permanent Sessions

Temporary Sessions

Temporary sessions are time based sessions, which by default will be deleted after 10 minutes, but you can specify for longer

Used as :

/**
 * access user session id
 */
Bot.TSession.id

/**
 * gets the whole session saved for user
 * @returns object of {user: ?, data:?}
 */
Bot.TSession.getSession();

/**
 * store specific key value for a specific amount of time
 * @param {string|number} key
 * @param {strin|number} value
 * @param {number} [timer=10M]
 */
Bot.TSession.setSessionValue(key, value, timer);

/**
 * get single value for specified key
 * @param {string|number} key
 * @returns value
 */
Bot.TSession.getSessionValue(key);

/**
 * store multiple key value pair specified in object
 * @param {object} Obj - object of key's and values
 * @param {number} [timer=10M]
 */
Bot.TSession.setSessionValues(Obj, timer);

/**
 * remove specific key value pair
 * @param {string|number} key - keys to be removed
 */
Bot.TSession.removeSessionValue(key);

/**
 * Delete complete session for the user
 */
Bot.TSession.deleteSession();

Permanent Sessions

Permanent sessions are sessions that can be stored forever

Used as :

/**
 * access user session id
 */
Bot.PSession.id

/**
 * gets the whole session saved for user
 * @returns object of {user: ?, data:?}
 */
Bot.PSession.getSession();

/**
 * store specific key value for a specific amount of time
 * @param {string|number} key
 * @param {strin|number} value
 */
Bot.TSession.setSessionValue(key, value);

/**
 * get single value for specified key
 * @param {string|number} key
 * @returns value
 */
Bot.TSession.getSessionValue(key);

/**
 * store multiple key value pair specified in object
 * @param {object} Obj - object of key's and values
 */
Bot.TSession.setSessionValues(Obj);

/**
 * remove specific key value pair
 * @param {string|number} key - keys to be removed
 */
Bot.PSession.removeSessionValue(key);

/**
 * Delete complete session for the user
 */
Bot.PSession.deleteSession();
Clone this wiki locally