Terminus-Project / Terminus-Bot

A scriptable IRC bot written in Ruby.
http://terminus-bot.net/
Other
38 stars 18 forks source link

User metadata #65

Open sariyamelody opened 10 years ago

sariyamelody commented 10 years ago

12:13:46 @Rylee | Kabaka, (aji and Shockk too), thoughts on a making the account system able to store metadata from scripts? lastfm username, weather location, f-list, etc 12:18:25 @Rylee | so what i was thinking was giving accounts a metadata section and exposing a store_metadata(account, key, data) instance method for scripts, when called it would update the given key with value under script_name under a metadata section in account

Xe commented 10 years ago

Honestly, you want at the least three functions:

  1. set_metadata (account, key, data) -> True if no collision, False if one
  2. del_metadata (account, key) -> the data it deleted or ruby's equivalent of null
  3. get_metadata (account, key) -> the data it looks up or ruby's null

I would be hesitant to make them script local, as it could allow developers to do interesting things with the metadata for other values. It might be better to make the default call for the metadata thing use the current script name as a key (which can be overloaded if you truly need to make an arbitrary key, maybe prefix script name?).

EDIT: "set" makes more sense than "add"