Feature: Send sentences from local
Closed this issue · 1 comments
It is possible to download hitokoto sentences bundle that open sourced in https://github.com/hitokoto-osc/sentences-bundle
via links mentioned in https://sentences-bundle.hitokoto.cn/ without the license.
So we can add an option to let user to switch to local database that stores these sentences.
Workaround:
Command Invoking
- Add an option named
source
with valuelocal
andremote
- When a user invoked command, check the value of
source
2.1 If the value isremote
, then request to the url ofapiUrl
to fetch the content.
2.2 If the value islocal
, then fetch content from databases (that means send-from-local requires database)
2.3 If the value islocal
, but there is no data, or it failed when fetch data from database (e.g. database disconnected), then print a warning message and goes 2.1. - Send the content that fetched above.
Bundle Cache Updating (only if database installed)
-
Add an option named
bundleEndpoint
, which would set tohttps://raw.githubusercontent.com/hitokoto-osc/sentences-bundle/master/
by default. (see https://sentences-bundle.hitokoto.cn/ for more information.)
1.1 Should also declare its license!! -
Add a progress bar or something similar in plugin configuration page, to indicate how large is the cache currently.
Format:- Hitokoto Sentences Cache:
<version> <count> sentences, <size>MiB.
- Remote Sentences Bundle:
<version> (update available)
- Shows
(update available)
only if remote differs to the local cache.
- Shows
2.1 If there is no data, says
No Data
; otherwise, display the size and count. - Hitokoto Sentences Cache:
-
Add a button in plugin configuration page, named
Fetch Cache
(if no data) orUpdate Cache
(if data exists)
3.1 If user clicked the button, then fetch data frombundleEndpoint
3.2 Update the information of cache once updated. -
Add a command named
hitokoto.cache
as a sub-command
4.1hitokoto.cache fetch
command: fetch the sentences bundle cache
4.2hitokoto.cache clear
command: clear the sentences bundle cache
4.3hitokoto.cache info
command: view the information of the current cache.
The format of the command should cover all the information that shows in 2).