-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use a static custom settings file to save user informationn #2712
Comments
i suggest that you do not edit the source code for such a trivial thing maybe look into https://github.com/HelloChatterbox/json_database but to answer your questions, you can send a bus message |
I agree with you. About json database my problem is how to load this database across over the skills and have this database consistent over all the skills in each moment, also if a skill modify some values. |
You should be able to do like this from a skill: Import the Message class from mycroft.messagebus import Message¨ Then in the initialize method of your skill have patch = {'user': 'arthur dent', 'password': 'yellow42'}
self.bus.emit(Message('configuration.patch', {'config': patch})) |
I'm thinking to create a my skill class that extends MycroftSkill Class and have in it a static dict only for the information about the user that i need, as well as a methods to load and write info on a file. In this way i have just to put this myclass on the same folder of Mycroftskill such a way that all skills can see it and extend it. |
It sounds like this will be a good use of the Skill API proposed in PR #1822 Rather than making the data structure available to all Skills, you could expose an API to interact with that data. Would that address the use case you're looking at? |
Closing Issue since we're archiving the repo |
I'm in trouble with this problem: I need to create a user id card where put some information about it, like name, surname, age, and so on.
I tried to add my own custom file a the mycroft main level called userinfo.conf, i added a class in configuration.py, locations.py and init.py to load this conf file with the other mycroft configurations file.
The loading work very well, I just used the existent classes in configuration.py to create my class to load the file.
But I'm in trouble with the consistency of the information saved on my own configuration file.
Let me explain: if i have a skill to set the name of the user, the skill sets the name of the user, using the dict given by MycroftSkill (config_core) and then calling a mine own method in configuration.py class to save this info on my own conf file.
But the problem is that cause the dict where MycroftSkill save the configuration information is not static, if a change the value in that dict, all the others skills can't see the new value, because they load the configuration information at creation time so where the MycroftSkill constructor is called.
I need something that all skills can be seen and that is consistent over all the skills, so that if a skill changes the same value, then that value is visible by all other skills.
I know that all skills have a configuration file to save some value, but if i have a skill for the name, one for the age, and so on and i save each info on proper skill configuration file, then the access to the info is very useless because I have the info fragmented in different skills configuration files.
What is the right way to solve this problem? I also want to avoid access to this hypothetic file every time I need to read some info, For example, if all my skills use the name value to call the user by name during the interaction, i don't want that each skill every time open a stream to the file to read the value.
for this reason i tried to exploit the mycroft pattern about configuration.
The text was updated successfully, but these errors were encountered: