添加题库支持,来源:科技强国
This commit is contained in:
parent
66c38ef5b0
commit
e3c3e0984b
|
@ -15,6 +15,7 @@ RUN apt-get -qq update && \
|
||||||
mkdir /opt/config/
|
mkdir /opt/config/
|
||||||
|
|
||||||
COPY conf/config_default.yml /opt/config/config.yml
|
COPY conf/config_default.yml /opt/config/config.yml
|
||||||
|
COPY conf/QuestionBank.db /opt/config/QuestionBank.db
|
||||||
|
|
||||||
COPY ./dist/docker_linux_$TARGETARCH*/study_xxqg /opt/study_xxqg
|
COPY ./dist/docker_linux_$TARGETARCH*/study_xxqg /opt/study_xxqg
|
||||||
|
|
||||||
|
|
Binary file not shown.
2
go.mod
2
go.mod
|
@ -6,7 +6,6 @@ replace github.com/willf/bitset v1.2.1 => github.com/bits-and-blooms/bitset v1.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
|
||||||
github.com/Luoxin/go-pushdeer-sdk v0.0.0-20220308071956-e50d1ec38c98
|
|
||||||
github.com/dustin/go-humanize v1.0.0
|
github.com/dustin/go-humanize v1.0.0
|
||||||
github.com/gin-gonic/gin v1.7.1
|
github.com/gin-gonic/gin v1.7.1
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.4.0-beta.0
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.4.0-beta.0
|
||||||
|
@ -36,7 +35,6 @@ require (
|
||||||
github.com/go-playground/locales v0.13.0 // indirect
|
github.com/go-playground/locales v0.13.0 // indirect
|
||||||
github.com/go-playground/universal-translator v0.17.0 // indirect
|
github.com/go-playground/universal-translator v0.17.0 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.5.0 // indirect
|
github.com/go-playground/validator/v10 v10.5.0 // indirect
|
||||||
github.com/go-resty/resty/v2 v2.7.0 // indirect
|
|
||||||
github.com/go-stack/stack v1.8.1 // indirect
|
github.com/go-stack/stack v1.8.1 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||||
|
|
7
go.sum
7
go.sum
|
@ -1,7 +1,5 @@
|
||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
|
||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
||||||
github.com/Luoxin/go-pushdeer-sdk v0.0.0-20220308071956-e50d1ec38c98 h1:88VEoycHG8Fecaf8h/Tq5FSP5Jjl1+yodHiPAJawDe0=
|
|
||||||
github.com/Luoxin/go-pushdeer-sdk v0.0.0-20220308071956-e50d1ec38c98/go.mod h1:ZO6lLdHMY7Hj7VDqvy+k+s5AQdkxK0KV08GU9CUuqR0=
|
|
||||||
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
|
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
||||||
|
@ -24,8 +22,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+
|
||||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||||
github.com/go-playground/validator/v10 v10.5.0 h1:X9rflw/KmpACwT8zdrm1upefpvdy6ur8d1kWyq6sg3E=
|
github.com/go-playground/validator/v10 v10.5.0 h1:X9rflw/KmpACwT8zdrm1upefpvdy6ur8d1kWyq6sg3E=
|
||||||
github.com/go-playground/validator/v10 v10.5.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk=
|
github.com/go-playground/validator/v10 v10.5.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk=
|
||||||
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
|
|
||||||
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
|
|
||||||
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
|
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
|
||||||
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
|
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.4.0-beta.0 h1:mbEDV1g6RBzKd4sFjOWuyZdxItw4CWu5Kq4KaBAJbHM=
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.4.0-beta.0 h1:mbEDV1g6RBzKd4sFjOWuyZdxItw4CWu5Kq4KaBAJbHM=
|
||||||
|
@ -113,7 +109,6 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qq
|
||||||
github.com/robfig/cron/v3 v3.0.0 h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E=
|
github.com/robfig/cron/v3 v3.0.0 h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E=
|
||||||
github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
|
||||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||||
|
@ -155,7 +150,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 h1:0FB83qp0AzVJm+0wcIlauAjJ+tNdh7jLuacRYCIVv7s=
|
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 h1:0FB83qp0AzVJm+0wcIlauAjJ+tNdh7jLuacRYCIVv7s=
|
||||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
@ -164,7 +158,6 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
|
|
@ -38,6 +38,11 @@ div > div.my-points-section > div.my-points-content > div:nth-child(6) > div.my-
|
||||||
* @param model
|
* @param model
|
||||||
*/
|
*/
|
||||||
func (c *Core) RespondDaily(user *model.User, model string) {
|
func (c *Core) RespondDaily(user *model.User, model string) {
|
||||||
|
|
||||||
|
var title string
|
||||||
|
retryTimes := 0
|
||||||
|
var id int
|
||||||
|
|
||||||
// 捕获所有异常,防止程序崩溃
|
// 捕获所有异常,防止程序崩溃
|
||||||
defer func() {
|
defer func() {
|
||||||
err := recover()
|
err := recover()
|
||||||
|
@ -135,7 +140,7 @@ func (c *Core) RespondDaily(user *model.User, model string) {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// 获取每周答题的ID
|
// 获取每周答题的ID
|
||||||
id, err := getweekID(user.ToCookies())
|
id, err = getweekID(user.ToCookies())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -167,10 +172,11 @@ func (c *Core) RespondDaily(user *model.User, model string) {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// 获取专项答题ID
|
// 获取专项答题ID
|
||||||
id, err := getSpecialID(user.ToCookies())
|
//id, err = getSpecialID(user.ToCookies())
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
id = 81
|
||||||
// 跳转到专项答题界面
|
// 跳转到专项答题界面
|
||||||
_, err = page.Goto(fmt.Sprintf("https://pc.xuexi.cn/points/exam-paper-detail.html?id=%d", id), playwright.PageGotoOptions{
|
_, err = page.Goto(fmt.Sprintf("https://pc.xuexi.cn/points/exam-paper-detail.html?id=%d", id), playwright.PageGotoOptions{
|
||||||
Referer: playwright.String(MyPointsUri),
|
Referer: playwright.String(MyPointsUri),
|
||||||
|
@ -312,7 +318,15 @@ func (c *Core) RespondDaily(user *model.User, model string) {
|
||||||
log.Errorln("获取题目问题失败" + err.Error())
|
log.Errorln("获取题目问题失败" + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infoln("## 题目:" + questionText)
|
log.Infoln("## 题目:" + questionText)
|
||||||
|
if title == questionText {
|
||||||
|
log.Warningln("可能已经卡住,正在重试,重试次数+1")
|
||||||
|
retryTimes++
|
||||||
|
} else {
|
||||||
|
retryTimes = 0
|
||||||
|
}
|
||||||
|
title = questionText
|
||||||
|
|
||||||
// 获取答题帮助
|
// 获取答题帮助
|
||||||
openTips, err := page.QuerySelector(
|
openTips, err := page.QuerySelector(
|
||||||
|
@ -349,6 +363,15 @@ func (c *Core) RespondDaily(user *model.User, model string) {
|
||||||
// 从整个页面内容获取提示信息
|
// 从整个页面内容获取提示信息
|
||||||
tips := getTips(content)
|
tips := getTips(content)
|
||||||
log.Infoln("[提示信息]:", tips)
|
log.Infoln("[提示信息]:", tips)
|
||||||
|
|
||||||
|
if retryTimes > 4 {
|
||||||
|
log.Warningln("重试次数太多,即将退出答题")
|
||||||
|
options, _ := getOptions(page)
|
||||||
|
c.Push(user.PushId, "flush", fmt.Sprintf(
|
||||||
|
"答题过程出现异常!!</br>答题渠道:%v</br>题目ID:%v</br>题目类型:%v</br>题目:%v</br>题目选项:%v</br>提示信息:%v</br>", model, id, categoryText, questionText, strings.Join(options, " "), strings.Join(tips, " ")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 填空题
|
// 填空题
|
||||||
switch {
|
switch {
|
||||||
case strings.Contains(categoryText, "填空题"):
|
case strings.Contains(categoryText, "填空题"):
|
||||||
|
@ -579,7 +602,19 @@ func FillBlank(page playwright.Page, tips []string) error {
|
||||||
video = true
|
video = true
|
||||||
}
|
}
|
||||||
if video {
|
if video {
|
||||||
answer = append(answer, "不知道")
|
data1, err := page.QuerySelector("#app > div > div.layout-body > div > div.detail-body > div.question > div.q-body > div > span:nth-child(1)")
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("获取题目前半段失败" + err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
data1Text, _ := data1.TextContent()
|
||||||
|
log.Infoln("题目前半段:=》" + data1Text)
|
||||||
|
searchAnswer := model.SearchAnswer(data1Text)
|
||||||
|
if searchAnswer != "" {
|
||||||
|
answer = append(answer, searchAnswer)
|
||||||
|
} else {
|
||||||
|
answer = append(answer, "不知道")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
answer = tips
|
answer = tips
|
||||||
}
|
}
|
||||||
|
@ -599,11 +634,12 @@ func FillBlank(page playwright.Page, tips []string) error {
|
||||||
}
|
}
|
||||||
var ans string
|
var ans string
|
||||||
for i := 0; i < len(inouts); i++ {
|
for i := 0; i < len(inouts); i++ {
|
||||||
if video {
|
if len(answer) < i+1 {
|
||||||
ans = "不知道"
|
ans = "不知道"
|
||||||
} else {
|
} else {
|
||||||
ans = answer[i]
|
ans = answer[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
err := inouts[i].Fill(ans)
|
err := inouts[i].Fill(ans)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("填充答案失败" + err.Error())
|
log.Errorln("填充答案失败" + err.Error())
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"sync"
|
||||||
|
|
||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
|
|
||||||
|
@ -10,6 +11,8 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
db *sql.DB
|
db *sql.DB
|
||||||
|
|
||||||
|
db1 *sql.DB
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -36,6 +39,18 @@ func init() {
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initQuestionDb() {
|
||||||
|
once := sync.Once{}
|
||||||
|
once.Do(func() {
|
||||||
|
var err error
|
||||||
|
db1, err = sql.Open("sqlite", "./config/QuestionBank.db")
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("题目数据库打开失败,请检查config目录权限")
|
||||||
|
log.Panicln(err.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func ping() {
|
func ping() {
|
||||||
err := db.Ping()
|
err := db.Ping()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
import log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
func SearchAnswer(title string) string {
|
||||||
|
initQuestionDb()
|
||||||
|
if db1 == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
var answer string
|
||||||
|
row := db1.QueryRow("select answer from tiku where question like ?", title+"%")
|
||||||
|
err := row.Scan(&answer)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln(err.Error())
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if answer == "" {
|
||||||
|
row := db1.QueryRow("select answer from tikuNet where question like ?", title+"%")
|
||||||
|
err := row.Scan(&answer)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln(err.Error())
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Infoln("从数据库查询到答案:" + answer)
|
||||||
|
return answer
|
||||||
|
}
|
22
push/tg.go
22
push/tg.go
|
@ -424,11 +424,23 @@ func study(bot *Telegram, from int64, args []string) {
|
||||||
defer datas.Delete(u)
|
defer datas.Delete(u)
|
||||||
core.Init()
|
core.Init()
|
||||||
defer core.Quit()
|
defer core.Quit()
|
||||||
core.LearnArticle(user)
|
if config.Model == 1 {
|
||||||
core.LearnVideo(user)
|
core.LearnArticle(user)
|
||||||
core.RespondDaily(user, "daily")
|
core.LearnVideo(user)
|
||||||
core.RespondDaily(user, "weekly")
|
} else if config.Model == 2 {
|
||||||
core.RespondDaily(user, "special")
|
core.LearnArticle(user)
|
||||||
|
core.LearnVideo(user)
|
||||||
|
core.RespondDaily(user, "daily")
|
||||||
|
} else if config.Model == 3 {
|
||||||
|
core.LearnArticle(user)
|
||||||
|
core.LearnVideo(user)
|
||||||
|
core.RespondDaily(user, "daily")
|
||||||
|
core.RespondDaily(user, "weekly")
|
||||||
|
core.RespondDaily(user, "special")
|
||||||
|
} else if config.Model == 4 {
|
||||||
|
core.RespondDaily(user, "special")
|
||||||
|
}
|
||||||
|
|
||||||
c <- 1
|
c <- 1
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue