MiniProgDevs / faqbot

faqbot for mp devs
0 stars 0 forks source link

import / add wechaty FAQ #1

Open dcsan opened 5 years ago

dcsan commented 5 years ago

FAQ exists here:

https://docs.chatie.io/faq https://github.com/Chatie/docs/blob/master/root/faq.md

dcsan commented 5 years ago

we should write an importer

q: some question
a: [ array of lines, for the answer ] 
tags: [ list, of, tags ]
dcsan commented 5 years ago

later

dcsan commented 5 years ago

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)
dcsan commented 5 years ago

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)"
 ]
}
dcsan commented 5 years ago

probably we should strip out the URL wrapping also as wechat text doesn't support markdown or html style URLs, just plain text.

dcsan commented 5 years ago

see commit above for where the stub function for this code is now.

dcsan commented 5 years ago

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.

dcsan commented 5 years ago

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

dcsan commented 5 years ago

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.

dcsan commented 5 years ago

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.