-\r
- # Bot-specific data can be stored with Irc::Users. This is\r
- # internally obtained by storing data to the associated BotUser,\r
- # but this is a detail plugin writers shouldn't care about.\r
- # bot_data(:key) can be used to retrieve a particular data set.\r
- # This method is intended for data retrieval, and if the retrieved\r
- # data is modified directly there is no guarantee the changes will\r
- # be saved back. Use #set_bot_data() for that.\r
- #\r
- def bot_data(key=nil)\r
- return self.botuser.data if key.nil?\r
- return self.botuser.data[key]\r
- end\r
-\r
- # This method is used to store bot-specific data for the receiver.\r
- # If no block is passed, _value_ is stored for the key _key_;\r
- # if a block is passed, it will be called with the previous\r
- # _key_ value as parameter, and its return value will be stored\r
- # as the new value. If _value_ is present in the block form, it\r
- # will be used to initialize _key_ if it's missing\r
- # \r
- def set_bot_data(key,value=nil,&block)\r
- if not block_given?\r
- self.botuser.data[key]=value\r
- Irc::Bot::Auth.manager.set_changed\r
- return value\r
- end\r
- if value and not bot_data.has_key?(key)\r
- set_bot_data(key, value)\r
- end\r
- r = value\r
- begin\r
- r = yield bot_data(key)\r
- ensure\r
- Irc::Bot::Auth.manager.set_changed\r
- end\r
- return r\r
- end\r