Konfigürasyon ve depolama¶
Konfigürasyon ve Kalıcı Depolama¶
As described in Altdizinler, each module has
been allocated with a folder per profile for configurations
and other storage. The path can be obtained using
get_data_path()
with your
module ID. All such storage is specific to only one
profile.
Konfigürasyonlar için, bunu kullanmanızı öneririz <module_data_path>/config.yaml
. Benzer olarak, bunu hazırladık :meth:`~.ehforwarderbot.utils.get_config_path`varsayılan konfig. dosyası için yolu alabilmek için. Yine, konfig. dosyanızın formatı için bu ismi veya YAML kullanmak için zorlanmıyorsunuz.
Genellikle depolama klasöründe bulunur:
Yapılandırma dosyaları
Kullanıcı kimlik bilgileri / Geçici depolama
Veri tabanları
Geçici Depolama¶
Multimedya mesajları işlenirken, kaçınılmaz olarak, belirli dosyaları geçici olarak, kanal içinde veya kanallar arasında saklamalıyız. Genellikle, geçici dosyalar Python’un tempfile
kütüphanesi ile işlenebilir.
Wizard¶
If your module requires relatively complicated configuration, it would be helpful to provide users with a wizard to check prerequisites of your module and guide them to setup your module for use.
From version 2, EFB introduced a centralised wizard program
to allow users to enable or disable modules in a text-based user
interface (TUI). If you want to include your wizard program as a part
of the wizard, you can include a new entry point in your setup.py
with Setuptools’ Entry Point feature.
The group for wizard program is ehforwarderbot.wizard
, and
the entry point function MUST accept 2 positional arguments:
profile ID and instance ID.
Example¶
setup.py
script
setup(
# ...
entry_points={
"ehforwarderbot.wizard": ['alice.irc = efb_irc_slave.wizard:main']
},
# ...
)
.egg-info/entry_points.txt
[ehforwarderbot.wizard]
alice.irc = efb_irc_slave.wizard:main
efb_irc_slave/wizard.py
# ...
def main(profile, instance):
print("Welcome to the setup wizard of my channel.")
print("You are setting up this channel in profile "
"'{0}' and instance '{1}'.".format(profile, instance))
print("Press ENTER/RETURN to continue.")
input()
step1()
# ...