test
This commit is contained in:
parent
e628d7303b
commit
0e7ba94f8b
5
bot.go
5
bot.go
@ -177,8 +177,11 @@ func botMsgDump(m *tb.Message) {
|
|||||||
r := regexp.MustCompile("^[0-9]+$")
|
r := regexp.MustCompile("^[0-9]+$")
|
||||||
if r.MatchString(m.Payload) {
|
if r.MatchString(m.Payload) {
|
||||||
objId, _ := strconv.ParseInt(m.Payload, 10, 64)
|
objId, _ := strconv.ParseInt(m.Payload, 10, 64)
|
||||||
objSubTypeId, err := getObjSubTypeId(objId)
|
objTypeId, err := getObjTypeId(objId)
|
||||||
|
logOnError(err, "botMsgDump : getObjSubTypeId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
res = `Error retrieving the message`
|
||||||
|
} else if objTypeId != objTypeMessage {
|
||||||
res = `This is not a message reference`
|
res = `This is not a message reference`
|
||||||
} else {
|
} else {
|
||||||
cwm, err := getMsg(objId)
|
cwm, err := getMsg(objId)
|
||||||
|
17
sql.go
17
sql.go
@ -1391,6 +1391,23 @@ func getMsg(objId int64) (*ChatWarsMessage, error) {
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getObjTypeId(objId int64) (int64, error) {
|
||||||
|
var objTypeId int64
|
||||||
|
|
||||||
|
stmt, err := db.Prepare(`SELECT o.obj_type_id FROM obj o WHERE o.id = ?`)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
defer stmt.Close()
|
||||||
|
|
||||||
|
err = stmt.QueryRow(objId).Scan(&objTypeId)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return objTypeId, nil
|
||||||
|
}
|
||||||
|
|
||||||
func getObjSubTypeId(objId int64) (int64, error) {
|
func getObjSubTypeId(objId int64) (int64, error) {
|
||||||
var objSubTypeId int64
|
var objSubTypeId int64
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user