Open dcsan opened 5 years ago
we should write an importer
read markdown files from a file location maybe in future we could write a scraper to parse web pages / markdown output, but that's more hassle.
convert to internal format
q: some question
a: [ array of lines, for the answer ]
tags: [ list, of, tags ]
later
let's assume a hierarchical format for the FAQs, #
is a section (category) and ##
is an individual FAQ.
then the actual FAQs could also be tagged with their category.
# FAQ
## 1. Cannot login
### 1.1 I can not login with my Wechat account
Wechat account that registered after 2017 will not be able to login via Web API. Learn more at [https://github.com/Chatie/wechaty/issues/872](https://github.com/Chatie/wechaty/issues/872)
Solution: Wechaty support protocols other than Web API, such as pad. Learn more at [https://github.com/Chatie/wechaty/issues/1296](https://github.com/Chatie/wechaty/issues/1296)
becomes
faq: {
{ category: "cannot login",
q: "I can not login with my Wechat account"
a: [
"Wechat account that registered after 2017 will not be able to login via Web API. Learn more at [https://github.com/Chatie/wechaty/issues/872](https://github.com/Chatie/wechaty/issues/872)",
"Solution: Wechaty support protocols other than Web API, such as pad. Learn more at [https://github.com/Chatie/wechaty/issues/1296](https://github.com/Chatie/wechaty/issues/1296)"
]
}
probably we should strip out the URL wrapping also as wechat text doesn't support markdown or html style URLs, just plain text.
see commit above for where the stub function for this code is now.
so this function could take an http URL in which case you would have to retrieve the raw text using eg axios. I think that's fine though.
another way is that we could retrieve the data locally first, and then you can just work on the file system, but that adds an extra step to pre-production.
actually
curl https://github.com/Chatie/docs/blob/master/root/faq.md
gets the html wiki editor.
you want the 'raw' URL
https://raw.githubusercontent.com/Chatie/docs/master/root/faq.md
btw this whole module could be moved to /utils/import/markdown.js
then the bot would just be passed the text output of the importer on initialize.
you could also add a 'slug' field to the output, this would be the title but turned into something to use as a URL, eg lowercase and replace spaces/punc with a dash.
title: I can not login with my Wechat account
becomes:
slug: I-can-not-login-with-my-Wechat-account
although I guess for URLs it's not case-sensitive.
FAQ exists here:
https://docs.chatie.io/faq https://github.com/Chatie/docs/blob/master/root/faq.md