test
This commit is contained in:
parent
2d31b02928
commit
ba6dc3e7ab
@ -1763,6 +1763,17 @@
|
|||||||
"Pumpkin"
|
"Pumpkin"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"item_type": "item_misc",
|
||||||
|
"code": "cst",
|
||||||
|
"weight": -1,
|
||||||
|
"exchange": "",
|
||||||
|
"auction": false,
|
||||||
|
"craftable": false,
|
||||||
|
"names": [
|
||||||
|
"Chaos stone"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"item_type": "item_misc",
|
"item_type": "item_misc",
|
||||||
"code": "pol",
|
"code": "pol",
|
||||||
|
1
def.go
1
def.go
@ -435,6 +435,7 @@ type MessageParsingRule struct {
|
|||||||
MsgTypeID64 int64
|
MsgTypeID64 int64
|
||||||
ChatID64 int64 `json:"chat_id"`
|
ChatID64 int64 `json:"chat_id"`
|
||||||
SenderUserID64 int64 `json:"sender_id"`
|
SenderUserID64 int64 `json:"sender_id"`
|
||||||
|
BotCommand bool `json:"bot_cmd"`
|
||||||
re *regexp.Regexp
|
re *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
31
rules.go
31
rules.go
@ -27,6 +27,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_job_gwithdraw_req`],
|
MsgTypeID64: cacheObjSubType[`msg_job_gwithdraw_req`],
|
||||||
ChatID64: cfg.Bot.Mainchat,
|
ChatID64: cfg.Bot.Mainchat,
|
||||||
SenderUserID64: int64(bot.Me.ID),
|
SenderUserID64: int64(bot.Me.ID),
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_shutdown`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_shutdown`],
|
||||||
ChatID64: cfg.Bot.Admin,
|
ChatID64: cfg.Bot.Admin,
|
||||||
SenderUserID64: 0,
|
SenderUserID64: 0,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -58,6 +60,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_user_config`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_user_config`],
|
||||||
ChatID64: id,
|
ChatID64: id,
|
||||||
SenderUserID64: id,
|
SenderUserID64: id,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -68,6 +71,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_pillage_on`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_pillage_on`],
|
||||||
ChatID64: id,
|
ChatID64: id,
|
||||||
SenderUserID64: id,
|
SenderUserID64: id,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -78,6 +82,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_pillage_off`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_pillage_off`],
|
||||||
ChatID64: id,
|
ChatID64: id,
|
||||||
SenderUserID64: id,
|
SenderUserID64: id,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -88,6 +93,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_def_guild`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_def_guild`],
|
||||||
ChatID64: id,
|
ChatID64: id,
|
||||||
SenderUserID64: id,
|
SenderUserID64: id,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -98,6 +104,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_def_castle`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_def_castle`],
|
||||||
ChatID64: id,
|
ChatID64: id,
|
||||||
SenderUserID64: id,
|
SenderUserID64: id,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -108,6 +115,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_alch_all`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_alch_all`],
|
||||||
ChatID64: id,
|
ChatID64: id,
|
||||||
SenderUserID64: id,
|
SenderUserID64: id,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -118,6 +126,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_deposit_on`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_deposit_on`],
|
||||||
ChatID64: id,
|
ChatID64: id,
|
||||||
SenderUserID64: id,
|
SenderUserID64: id,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -128,6 +137,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_deposit_off`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_deposit_off`],
|
||||||
ChatID64: id,
|
ChatID64: id,
|
||||||
SenderUserID64: id,
|
SenderUserID64: id,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
}
|
}
|
||||||
@ -146,6 +156,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_craft_item`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_craft_item`],
|
||||||
ChatID64: chats[id],
|
ChatID64: chats[id],
|
||||||
SenderUserID64: users[id],
|
SenderUserID64: users[id],
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
}
|
}
|
||||||
@ -159,6 +170,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_g_stock`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_g_stock`],
|
||||||
ChatID64: chats[id],
|
ChatID64: chats[id],
|
||||||
SenderUserID64: users[id],
|
SenderUserID64: users[id],
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -169,6 +181,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_shops`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_shops`],
|
||||||
ChatID64: chats[id],
|
ChatID64: chats[id],
|
||||||
SenderUserID64: users[id],
|
SenderUserID64: users[id],
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -179,6 +192,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_job_gwithdraw_ack`],
|
MsgTypeID64: cacheObjSubType[`msg_job_gwithdraw_ack`],
|
||||||
ChatID64: chats[id],
|
ChatID64: chats[id],
|
||||||
SenderUserID64: users[id],
|
SenderUserID64: users[id],
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -189,6 +203,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_craft_all`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_craft_all`],
|
||||||
ChatID64: chats[id],
|
ChatID64: chats[id],
|
||||||
SenderUserID64: users[id],
|
SenderUserID64: users[id],
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -199,6 +214,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_get_stash`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_get_stash`],
|
||||||
ChatID64: chats[id],
|
ChatID64: chats[id],
|
||||||
SenderUserID64: users[id],
|
SenderUserID64: users[id],
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -212,6 +228,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_rage_up`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_rage_up`],
|
||||||
ChatID64: cfg.Bot.Mainchat,
|
ChatID64: cfg.Bot.Mainchat,
|
||||||
SenderUserID64: 0,
|
SenderUserID64: 0,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -222,6 +239,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgTypeID64: cacheObjSubType[`msg_bot_peace_up`],
|
MsgTypeID64: cacheObjSubType[`msg_bot_peace_up`],
|
||||||
ChatID64: cfg.Bot.Mainchat,
|
ChatID64: cfg.Bot.Mainchat,
|
||||||
SenderUserID64: 0,
|
SenderUserID64: 0,
|
||||||
|
BotCommand: true,
|
||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
@ -254,6 +272,7 @@ func resetMsgParsingRules() error {
|
|||||||
MsgType: r.MsgType,
|
MsgType: r.MsgType,
|
||||||
ChatID64: r.ChatID64,
|
ChatID64: r.ChatID64,
|
||||||
SenderUserID64: r.SenderUserID64,
|
SenderUserID64: r.SenderUserID64,
|
||||||
|
BotCommand: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
r2.MsgTypeID64, err = codeObjSubTypeId(r2.MsgType)
|
r2.MsgTypeID64, err = codeObjSubTypeId(r2.MsgType)
|
||||||
@ -278,8 +297,8 @@ func resetMsgParsingRules() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt, err := db.Prepare(`INSERT INTO msg_rules (prio, msg_type_id, chat_id, user_id, descn, rule)
|
stmt, err := db.Prepare(`INSERT INTO msg_rules (prio, msg_type_id, chat_id, user_id, descn, bot_cmd, rule)
|
||||||
VALUES (?, ?, ?, ?, ?, ?);`)
|
VALUES (?, ?, ?, ?, ?, ?, ?);`)
|
||||||
logOnError(err, "resetMsgParsingRules : prepare statement")
|
logOnError(err, "resetMsgParsingRules : prepare statement")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -287,7 +306,7 @@ func resetMsgParsingRules() error {
|
|||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
count = 0
|
count = 0
|
||||||
for _, r2 := range rules2 {
|
for _, r2 := range rules2 {
|
||||||
_, err = stmt.Exec(r2.Priority, r2.MsgTypeID64, r2.ChatID64, r2.SenderUserID64, r2.Description, r2.Rule)
|
_, err = stmt.Exec(r2.Priority, r2.MsgTypeID64, r2.ChatID64, r2.SenderUserID64, r2.Description, r2.BotCommand, r2.Rule)
|
||||||
logOnError(err, "resetMsgParsingRules : insert statement "+r2.Description)
|
logOnError(err, "resetMsgParsingRules : insert statement "+r2.Description)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -311,6 +330,7 @@ func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
|
|||||||
msgTypeID64 int64
|
msgTypeID64 int64
|
||||||
chatID64 int64
|
chatID64 int64
|
||||||
userID64 int64
|
userID64 int64
|
||||||
|
botCommand bool
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Println("Loading message parsing rules...")
|
log.Println("Loading message parsing rules...")
|
||||||
@ -324,14 +344,14 @@ func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
rules, err := db.Query(`SELECT r.id, r.prio, r.descn, r.rule, r.msg_type_id, r.chat_id, r.user_id FROM msg_rules r ORDER BY r.prio DESC;`)
|
rules, err := db.Query(`SELECT r.id, r.prio, r.descn, r.rule, r.msg_type_id, r.chat_id, r.user_id, r.bot_cmd FROM msg_rules r ORDER BY r.prio DESC;`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return m, err
|
return m, err
|
||||||
}
|
}
|
||||||
defer rules.Close()
|
defer rules.Close()
|
||||||
|
|
||||||
for rules.Next() {
|
for rules.Next() {
|
||||||
err = rules.Scan(&id, &priority, &descn, &rule, &msgTypeID64, &chatID64, &userID64)
|
err = rules.Scan(&id, &priority, &descn, &rule, &msgTypeID64, &chatID64, &userID64, &botCommand)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return m, err
|
return m, err
|
||||||
}
|
}
|
||||||
@ -343,6 +363,7 @@ func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
|
|||||||
i.MsgTypeID64 = msgTypeID64
|
i.MsgTypeID64 = msgTypeID64
|
||||||
i.ChatID64 = chatID64
|
i.ChatID64 = chatID64
|
||||||
i.SenderUserID64 = userID64
|
i.SenderUserID64 = userID64
|
||||||
|
i.BotCommand = botCommand
|
||||||
i.re = regexp.MustCompile(rule)
|
i.re = regexp.MustCompile(rule)
|
||||||
m[count] = *i
|
m[count] = *i
|
||||||
// log.Printf("New rule : %s\n", rule)
|
// log.Printf("New rule : %s\n", rule)
|
||||||
|
1
sql.go
1
sql.go
@ -402,6 +402,7 @@ func initDB() {
|
|||||||
,msg_type_id SMALLINT UNSIGNED NOT NULL
|
,msg_type_id SMALLINT UNSIGNED NOT NULL
|
||||||
,chat_id BIGINT NOT NULL
|
,chat_id BIGINT NOT NULL
|
||||||
,user_id BIGINT NOT NULL
|
,user_id BIGINT NOT NULL
|
||||||
|
,bot_cmd TINYINT NOT NULL
|
||||||
,UNIQUE KEY (id)
|
,UNIQUE KEY (id)
|
||||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
|
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
|
||||||
failOnError(err, "initDB : create table msg_rules")
|
failOnError(err, "initDB : create table msg_rules")
|
||||||
|
468
workers.go
468
workers.go
@ -353,245 +353,249 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
} else {
|
} else {
|
||||||
err = setObjSubTypeId(objId, rule.MsgTypeID64)
|
err = setObjSubTypeId(objId, rule.MsgTypeID64)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId")
|
||||||
switch rule.MsgTypeID64 {
|
if rule.BotCommand && m.Date.Add(time.Minute).After(time.Now().UTC()) {
|
||||||
case cacheObjSubType[`msg_groles_req`]:
|
log.Printf("SQLIdentifyMsgWorker[" + strconv.Itoa(id) + "] : Timed out command\n")
|
||||||
case cacheObjSubType[`msg_go`]:
|
} else {
|
||||||
case cacheObjSubType[`msg_report_req`]:
|
switch rule.MsgTypeID64 {
|
||||||
case cacheObjSubType[`msg_g_report_req`]:
|
case cacheObjSubType[`msg_groles_req`]:
|
||||||
case cacheObjSubType[`msg_hero_req`]:
|
case cacheObjSubType[`msg_go`]:
|
||||||
case cacheObjSubType[`msg_me_req`]:
|
case cacheObjSubType[`msg_report_req`]:
|
||||||
case cacheObjSubType[`msg_inv_req`]:
|
case cacheObjSubType[`msg_g_report_req`]:
|
||||||
case cacheObjSubType[`msg_time_req`]:
|
case cacheObjSubType[`msg_hero_req`]:
|
||||||
case cacheObjSubType[`msg_pledge`]:
|
case cacheObjSubType[`msg_me_req`]:
|
||||||
case cacheObjSubType[`msg_pillage_go`]:
|
case cacheObjSubType[`msg_inv_req`]:
|
||||||
case cacheObjSubType[`msg_pillage_timeout`]:
|
case cacheObjSubType[`msg_time_req`]:
|
||||||
case cacheObjSubType[`msg_pillage_win`]:
|
case cacheObjSubType[`msg_pledge`]:
|
||||||
case cacheObjSubType[`msg_pillage_loss`]:
|
case cacheObjSubType[`msg_pillage_go`]:
|
||||||
case cacheObjSubType[`msg_go_quest_req`]:
|
case cacheObjSubType[`msg_pillage_timeout`]:
|
||||||
case cacheObjSubType[`msg_fast_fight`]:
|
case cacheObjSubType[`msg_pillage_win`]:
|
||||||
case cacheObjSubType[`msg_go_arena`]:
|
case cacheObjSubType[`msg_pillage_loss`]:
|
||||||
case cacheObjSubType[`msg_top_req`]:
|
case cacheObjSubType[`msg_go_quest_req`]:
|
||||||
case cacheObjSubType[`msg_menu`]:
|
case cacheObjSubType[`msg_fast_fight`]:
|
||||||
case cacheObjSubType[`msg_buy_req`]:
|
case cacheObjSubType[`msg_go_arena`]:
|
||||||
case cacheObjSubType[`msg_sell_req`]:
|
case cacheObjSubType[`msg_top_req`]:
|
||||||
case cacheObjSubType[`msg_orderbook_req`]:
|
case cacheObjSubType[`msg_menu`]:
|
||||||
case cacheObjSubType[`msg_withdraw_req`]:
|
case cacheObjSubType[`msg_buy_req`]:
|
||||||
case cacheObjSubType[`msg_withdraw_code`]:
|
case cacheObjSubType[`msg_sell_req`]:
|
||||||
case cacheObjSubType[`msg_withdraw_rcv`]:
|
case cacheObjSubType[`msg_orderbook_req`]:
|
||||||
cwm, err := parseSubTypeMessageWithdrawRcv(m, rule.re)
|
case cacheObjSubType[`msg_withdraw_req`]:
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_withdraw_rcv`]")
|
case cacheObjSubType[`msg_withdraw_code`]:
|
||||||
for _, i := range cwm.ItemList {
|
case cacheObjSubType[`msg_withdraw_rcv`]:
|
||||||
err = insertMsgItem(cwm.Msg.ObjID64, i.ItemID64, i.Quantity)
|
cwm, err := parseSubTypeMessageWithdrawRcv(m, rule.re)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Inserting cacheObjSubType[`msg_withdraw_rcv`]")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_withdraw_rcv`]")
|
||||||
}
|
for _, i := range cwm.ItemList {
|
||||||
case cacheObjSubType[`msg_stock_req`]:
|
err = insertMsgItem(cwm.Msg.ObjID64, i.ItemID64, i.Quantity)
|
||||||
case cacheObjSubType[`msg_misc_req`]:
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Inserting cacheObjSubType[`msg_withdraw_rcv`]")
|
||||||
case cacheObjSubType[`msg_gstock_res_req`]:
|
}
|
||||||
case cacheObjSubType[`msg_gstock_alch_req`]:
|
case cacheObjSubType[`msg_stock_req`]:
|
||||||
case cacheObjSubType[`msg_gstock_misc_req`]:
|
case cacheObjSubType[`msg_misc_req`]:
|
||||||
case cacheObjSubType[`msg_gstock_rec_req`]:
|
case cacheObjSubType[`msg_gstock_res_req`]:
|
||||||
case cacheObjSubType[`msg_gstock_part_req`]:
|
case cacheObjSubType[`msg_gstock_alch_req`]:
|
||||||
case cacheObjSubType[`msg_gstock_oth_req`]:
|
case cacheObjSubType[`msg_gstock_misc_req`]:
|
||||||
case cacheObjSubType[`msg_gstock_any_ack`]:
|
case cacheObjSubType[`msg_gstock_rec_req`]:
|
||||||
_, err := parseSubTypeMessageGStockAnyAck(m, rule.re)
|
case cacheObjSubType[`msg_gstock_part_req`]:
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_gstock_any_ack`]")
|
case cacheObjSubType[`msg_gstock_oth_req`]:
|
||||||
case cacheObjSubType[`msg_report_ack`]:
|
case cacheObjSubType[`msg_gstock_any_ack`]:
|
||||||
cwm, err := parseSubTypeMessageReportAck(m, rule.re)
|
_, err := parseSubTypeMessageGStockAnyAck(m, rule.re)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_report_ack`]")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_gstock_any_ack`]")
|
||||||
cwm.ObjID64 = objId
|
case cacheObjSubType[`msg_report_ack`]:
|
||||||
case cacheObjSubType[`msg_quest_res_ambush`]:
|
cwm, err := parseSubTypeMessageReportAck(m, rule.re)
|
||||||
cwm, err := parseSubTypeMessageQuestResultAmbush(m, rule.re)
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_report_ack`]")
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res_ambush`]")
|
cwm.ObjID64 = objId
|
||||||
if m.Date.Add(3 * time.Minute).After(time.Now().UTC()) {
|
case cacheObjSubType[`msg_quest_res_ambush`]:
|
||||||
if m.ChatID64 == chtwrsbotID64 && m.TGSenderUserID64 == chtwrsbotID64 {
|
cwm, err := parseSubTypeMessageQuestResultAmbush(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res_ambush`]")
|
||||||
|
if m.Date.Add(3 * time.Minute).After(time.Now().UTC()) {
|
||||||
|
if m.ChatID64 == chtwrsbotID64 && m.TGSenderUserID64 == chtwrsbotID64 {
|
||||||
|
s := TGCommand{
|
||||||
|
Type: commandForwardMsg,
|
||||||
|
FromUserID64: m.TGUserID64,
|
||||||
|
FromMsgID64: m.ID64,
|
||||||
|
FromChatID64: m.ChatID64,
|
||||||
|
ToChatID64: angrybirbsbotID64,
|
||||||
|
}
|
||||||
|
MQTGCmdQueue <- s
|
||||||
|
} else if m.ChatID64 == cfg.Bot.Mainchat {
|
||||||
|
err = clientSpreadQuestResultAmbush(cwm)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : clientSpreadQuestResultAmbush.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case cacheObjSubType[`msg_pillage_inc`]:
|
||||||
|
fallthrough
|
||||||
|
case cacheObjSubType[`msg_pillage_inc2`]:
|
||||||
|
cwm, err := parseSubTypeMessagePillageInc(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_pillage_inc`]")
|
||||||
|
cwm.ObjID64 = objId
|
||||||
|
err = insertMsgPillageInc(cwm)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgPillageInc")
|
||||||
|
// only catch live pillages
|
||||||
|
if m.Date.Add(3*time.Minute).After(time.Now()) && m.ChatID64 == chtwrsbotID64 {
|
||||||
s := TGCommand{
|
s := TGCommand{
|
||||||
Type: commandForwardMsg,
|
Type: commandSendMsg,
|
||||||
FromUserID64: m.TGUserID64,
|
Text: fmt.Sprintf("Catching pillage (%s)", m.Date.Format(time.RFC3339)),
|
||||||
FromMsgID64: m.ID64,
|
ToUserID64: m.TGUserID64,
|
||||||
FromChatID64: m.ChatID64,
|
|
||||||
ToChatID64: angrybirbsbotID64,
|
|
||||||
}
|
}
|
||||||
MQTGCmdQueue <- s
|
TGCmdQueue <- s
|
||||||
} else if m.ChatID64 == cfg.Bot.Mainchat {
|
p := JobPayloadPillage{
|
||||||
err = clientSpreadQuestResultAmbush(cwm)
|
ObjID64: objId,
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : clientSpreadQuestResultAmbush.")
|
Date: m.Date,
|
||||||
}
|
|
||||||
}
|
|
||||||
case cacheObjSubType[`msg_pillage_inc`]:
|
|
||||||
fallthrough
|
|
||||||
case cacheObjSubType[`msg_pillage_inc2`]:
|
|
||||||
cwm, err := parseSubTypeMessagePillageInc(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_pillage_inc`]")
|
|
||||||
cwm.ObjID64 = objId
|
|
||||||
err = insertMsgPillageInc(cwm)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgPillageInc")
|
|
||||||
// only catch live pillages
|
|
||||||
if m.Date.Add(3*time.Minute).After(time.Now()) && m.ChatID64 == chtwrsbotID64 {
|
|
||||||
s := TGCommand{
|
|
||||||
Type: commandSendMsg,
|
|
||||||
Text: fmt.Sprintf("Catching pillage (%s)", m.Date.Format(time.RFC3339)),
|
|
||||||
ToUserID64: m.TGUserID64,
|
|
||||||
}
|
|
||||||
TGCmdQueue <- s
|
|
||||||
p := JobPayloadPillage{
|
|
||||||
ObjID64: objId,
|
|
||||||
Date: m.Date,
|
|
||||||
}
|
|
||||||
b, _ := json.Marshal(&p)
|
|
||||||
_, err = createJob(cacheObjSubType[`job_pillage`], objJobPriority, m.TGUserID64, m.ObjID64, m.Date.Add(time.Duration(25+rand.Intn(35))*time.Second), b)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : createJob(JobPillage)")
|
|
||||||
}
|
|
||||||
case cacheObjSubType[`msg_me_ack`]:
|
|
||||||
cwm, err := parseSubTypeMessageMeAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_me_ack`]")
|
|
||||||
clientMsgMeAck(cwm)
|
|
||||||
_, err = addObjXP(cwm.CWUserID64, cwm.ExpNow, cwm.ExpLvl, cwm.Level, m.Date)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : addObjXP(MeAck)")
|
|
||||||
case cacheObjSubType[`msg_go_quest_ack`]:
|
|
||||||
cwm, err := parseSubTypeMessageGoQuestAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_go_quest_ack`]")
|
|
||||||
uid, err := clientGetCWUserID64(m.TGUserID64)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving UserID64.")
|
|
||||||
if err != nil {
|
|
||||||
err = setObjSubTypeId(objId, cacheObjSubType[`msg`])
|
|
||||||
} else {
|
|
||||||
clientMsgGoQuestAck(cwm)
|
|
||||||
_, err = addObjQuest(uid, cwm.QuestTypeID64, cwm.Duration, m.Date.UTC())
|
|
||||||
}
|
|
||||||
err = setClientBusy(m.TGUserID64, m.Date, cwm.Duration)
|
|
||||||
case cacheObjSubType[`msg_duel_fight`]:
|
|
||||||
cwm, err := parseSubTypeMessageDuelFight(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_duel_fight`]")
|
|
||||||
cwm.ObjID64 = objId
|
|
||||||
err = insertMsgDuelFight(cwm)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgDuelFight")
|
|
||||||
case cacheObjSubType[`msg_union_war`]:
|
|
||||||
_, err := parseSubTypeMessageUnionWar(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_union_war`]")
|
|
||||||
case cacheObjSubType[`msg_groles_ack`]:
|
|
||||||
cwm, err := parseSubTypeMessageGRolesAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_groles_ack`]")
|
|
||||||
clientMsgGRolesAck(cwm)
|
|
||||||
case cacheObjSubType[`msg_auction_announce`]:
|
|
||||||
cwm, err := parseSubTypeMessageAuctionAnnounce(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_auction_announce`]")
|
|
||||||
cwm.ObjID64 = objId
|
|
||||||
err = insertMsgAuctionAnnounce(cwm)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgAuctionAnnounce")
|
|
||||||
if cwm.End.After(time.Now().UTC()) || strings.Compare(cwm.Status, `#active`) == 0 {
|
|
||||||
p := JobPayloadMsgRefresh{
|
|
||||||
ObjID64: m.ObjID64,
|
|
||||||
}
|
|
||||||
b, _ := json.Marshal(&p)
|
|
||||||
_, err = createJob(cacheObjSubType[`job_msg_refresh`], objJobPriority, m.TGUserID64, m.ObjID64, cwm.End.Add(5*time.Minute).UTC(), b)
|
|
||||||
/* hack for autobid - FIXME */
|
|
||||||
/*
|
|
||||||
if cwm.Price == 0 && cwm.ItemID64 == getObjItemID(`k05`, `Hunter blade`) {
|
|
||||||
clientSendCWMsg(cfg.Bot.Admin, fmt.Sprintf("/bet_%d_1", cwm.LotID))
|
|
||||||
}
|
}
|
||||||
*/
|
b, _ := json.Marshal(&p)
|
||||||
}
|
_, err = createJob(cacheObjSubType[`job_pillage`], objJobPriority, m.TGUserID64, m.ObjID64, m.Date.Add(time.Duration(25+rand.Intn(35))*time.Second), b)
|
||||||
case cacheObjSubType[`msg_time_ack`]:
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : createJob(JobPillage)")
|
||||||
_, err := parseSubTypeMessageTimeAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_time_ack`]")
|
|
||||||
case cacheObjSubType[`msg_orderbook_acl`]:
|
|
||||||
_, err := parseSubTypeMessageOrderbookAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_orderbook_acl`]")
|
|
||||||
case cacheObjSubType[`msg_stock_ack`]:
|
|
||||||
_, err := parseSubTypeMessageStockAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_ack`]")
|
|
||||||
case cacheObjSubType[`msg_g_deposit_req`]:
|
|
||||||
_, err := parseSubTypeMessageGDepositReq(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_g_deposit_req`]")
|
|
||||||
case cacheObjSubType[`msg_g_deposit_ack`]:
|
|
||||||
cwm, err := parseSubTypeMessageGDepositAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_g_deposit_ack`]")
|
|
||||||
err = insertMsgItem(cwm.Msg.ObjID64, cwm.ItemID64, cwm.Quantity)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Inserting cacheObjSubType[`msg_g_deposit_ack`]")
|
|
||||||
case cacheObjSubType[`msg_stock_any_ack`]:
|
|
||||||
_, err := parseSubTypeMessageStockAnyAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_any_ack`]")
|
|
||||||
case cacheObjSubType[`msg_exchange_ack`]:
|
|
||||||
_, err := parseSubTypeMessageExchangeAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_exchange_ack`]")
|
|
||||||
case cacheObjSubType[`msg_quest_res`]:
|
|
||||||
_, err := parseSubTypeMessageQuestResult(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res`]")
|
|
||||||
err = setClientIdle(m.TGUserID64, m.Date)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setClientIdle")
|
|
||||||
case cacheObjSubType[`msg_job_gwithdraw_ack`]:
|
|
||||||
_, err := parseSubTypeMessageJobGWithdrawAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res`]")
|
|
||||||
case cacheObjSubType[`msg_bot_g_stock`]:
|
|
||||||
botGStock(m)
|
|
||||||
case cacheObjSubType[`msg_bot_shops`]:
|
|
||||||
botShops(m)
|
|
||||||
case cacheObjSubType[`msg_bot_craft_item`]:
|
|
||||||
botCraftItem(m, rule.re)
|
|
||||||
case cacheObjSubType[`msg_bot_craft_all`]:
|
|
||||||
botCraftAll(m, rule.re)
|
|
||||||
case cacheObjSubType[`msg_bot_get_stash`]:
|
|
||||||
botGetStash(m, rule.re)
|
|
||||||
case cacheObjSubType[`msg_tributes_stats_req`]:
|
|
||||||
case cacheObjSubType[`msg_tributes_stats_ack`]:
|
|
||||||
cwm, err := parseSubTypeMessageTributesStatsAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_tributes_stats_ack`]")
|
|
||||||
err = insertMsgTributesStats(cwm)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgTributesStats")
|
|
||||||
case cacheObjSubType[`msg_shop_main_req`]:
|
|
||||||
case cacheObjSubType[`msg_shop_main_ack`]:
|
|
||||||
cwm, err := parseSubTypeMessageShopMainAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_shop_main_ack`]")
|
|
||||||
err = insertMsgShopMainAck(cwm)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgShopMainAck")
|
|
||||||
case cacheObjSubType[`msg_bot_user_config`]:
|
|
||||||
botUserConfig(m)
|
|
||||||
case cacheObjSubType[`msg_bot_user_config_pillage_on`]:
|
|
||||||
botUserConfigPillage(m, true)
|
|
||||||
case cacheObjSubType[`msg_bot_user_config_pillage_off`]:
|
|
||||||
botUserConfigPillage(m, false)
|
|
||||||
case cacheObjSubType[`msg_bot_user_config_def_guild`]:
|
|
||||||
botUserConfigWartime(m, `/g_def`)
|
|
||||||
case cacheObjSubType[`msg_bot_user_config_def_castle`]:
|
|
||||||
botUserConfigWartime(m, `🛡Defend`)
|
|
||||||
case cacheObjSubType[`msg_bot_user_config_deposit_on`]:
|
|
||||||
botUserConfigDeposit(m, true)
|
|
||||||
case cacheObjSubType[`msg_bot_user_config_deposit_off`]:
|
|
||||||
botUserConfigDeposit(m, false)
|
|
||||||
case cacheObjSubType[`msg_bot_shutdown`]:
|
|
||||||
botShutdown()
|
|
||||||
case cacheObjSubType[`msg_bot_rage_up`]:
|
|
||||||
case cacheObjSubType[`msg_bot_peace_up`]:
|
|
||||||
case cacheObjSubType[`msg_bot_alch_all`]:
|
|
||||||
botAlchAll(m)
|
|
||||||
case cacheObjSubType[`msg_alch_stock_req`]:
|
|
||||||
case cacheObjSubType[`msg_alch_stock_ack`]:
|
|
||||||
_, err := parseSubTypeMessageAlchStockAck(m, rule.re)
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_alch_stock_ack`]")
|
|
||||||
case cacheObjSubType[`msg_skill_too_low`]:
|
|
||||||
default:
|
|
||||||
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID64, objId, m.Text)
|
|
||||||
}
|
|
||||||
muxCallbacks.Lock()
|
|
||||||
if mc1, mok1 := callbacks[m.TGUserID64]; mok1 {
|
|
||||||
if mc2, mok2 := mc1[rule.MsgTypeID64]; mok2 {
|
|
||||||
for j := range mc2 {
|
|
||||||
err := rescheduleJob(mc2[j], m.ObjID64, time.Now().UTC())
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : callbacks triggering")
|
|
||||||
}
|
}
|
||||||
mc1[rule.MsgTypeID64] = nil
|
case cacheObjSubType[`msg_me_ack`]:
|
||||||
}
|
cwm, err := parseSubTypeMessageMeAck(m, rule.re)
|
||||||
}
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_me_ack`]")
|
||||||
if mc1, mok1 := callbacks[int64(bot.Me.ID)]; mok1 {
|
clientMsgMeAck(cwm)
|
||||||
if mc2, mok2 := mc1[rule.MsgTypeID64]; mok2 {
|
_, err = addObjXP(cwm.CWUserID64, cwm.ExpNow, cwm.ExpLvl, cwm.Level, m.Date)
|
||||||
for j := range mc2 {
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : addObjXP(MeAck)")
|
||||||
err := rescheduleJob(mc2[j], m.ObjID64, time.Now().UTC())
|
case cacheObjSubType[`msg_go_quest_ack`]:
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : callbacks triggering")
|
cwm, err := parseSubTypeMessageGoQuestAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_go_quest_ack`]")
|
||||||
|
uid, err := clientGetCWUserID64(m.TGUserID64)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving UserID64.")
|
||||||
|
if err != nil {
|
||||||
|
err = setObjSubTypeId(objId, cacheObjSubType[`msg`])
|
||||||
|
} else {
|
||||||
|
clientMsgGoQuestAck(cwm)
|
||||||
|
_, err = addObjQuest(uid, cwm.QuestTypeID64, cwm.Duration, m.Date.UTC())
|
||||||
}
|
}
|
||||||
mc1[rule.MsgTypeID64] = nil
|
err = setClientBusy(m.TGUserID64, m.Date, cwm.Duration)
|
||||||
|
case cacheObjSubType[`msg_duel_fight`]:
|
||||||
|
cwm, err := parseSubTypeMessageDuelFight(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_duel_fight`]")
|
||||||
|
cwm.ObjID64 = objId
|
||||||
|
err = insertMsgDuelFight(cwm)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgDuelFight")
|
||||||
|
case cacheObjSubType[`msg_union_war`]:
|
||||||
|
_, err := parseSubTypeMessageUnionWar(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_union_war`]")
|
||||||
|
case cacheObjSubType[`msg_groles_ack`]:
|
||||||
|
cwm, err := parseSubTypeMessageGRolesAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_groles_ack`]")
|
||||||
|
clientMsgGRolesAck(cwm)
|
||||||
|
case cacheObjSubType[`msg_auction_announce`]:
|
||||||
|
cwm, err := parseSubTypeMessageAuctionAnnounce(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_auction_announce`]")
|
||||||
|
cwm.ObjID64 = objId
|
||||||
|
err = insertMsgAuctionAnnounce(cwm)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgAuctionAnnounce")
|
||||||
|
if cwm.End.After(time.Now().UTC()) || strings.Compare(cwm.Status, `#active`) == 0 {
|
||||||
|
p := JobPayloadMsgRefresh{
|
||||||
|
ObjID64: m.ObjID64,
|
||||||
|
}
|
||||||
|
b, _ := json.Marshal(&p)
|
||||||
|
_, err = createJob(cacheObjSubType[`job_msg_refresh`], objJobPriority, m.TGUserID64, m.ObjID64, cwm.End.Add(5*time.Minute).UTC(), b)
|
||||||
|
/* hack for autobid - FIXME */
|
||||||
|
/*
|
||||||
|
if cwm.Price == 0 && cwm.ItemID64 == getObjItemID(`k05`, `Hunter blade`) {
|
||||||
|
clientSendCWMsg(cfg.Bot.Admin, fmt.Sprintf("/bet_%d_1", cwm.LotID))
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
case cacheObjSubType[`msg_time_ack`]:
|
||||||
|
_, err := parseSubTypeMessageTimeAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_time_ack`]")
|
||||||
|
case cacheObjSubType[`msg_orderbook_acl`]:
|
||||||
|
_, err := parseSubTypeMessageOrderbookAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_orderbook_acl`]")
|
||||||
|
case cacheObjSubType[`msg_stock_ack`]:
|
||||||
|
_, err := parseSubTypeMessageStockAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_ack`]")
|
||||||
|
case cacheObjSubType[`msg_g_deposit_req`]:
|
||||||
|
_, err := parseSubTypeMessageGDepositReq(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_g_deposit_req`]")
|
||||||
|
case cacheObjSubType[`msg_g_deposit_ack`]:
|
||||||
|
cwm, err := parseSubTypeMessageGDepositAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_g_deposit_ack`]")
|
||||||
|
err = insertMsgItem(cwm.Msg.ObjID64, cwm.ItemID64, cwm.Quantity)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Inserting cacheObjSubType[`msg_g_deposit_ack`]")
|
||||||
|
case cacheObjSubType[`msg_stock_any_ack`]:
|
||||||
|
_, err := parseSubTypeMessageStockAnyAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_any_ack`]")
|
||||||
|
case cacheObjSubType[`msg_exchange_ack`]:
|
||||||
|
_, err := parseSubTypeMessageExchangeAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_exchange_ack`]")
|
||||||
|
case cacheObjSubType[`msg_quest_res`]:
|
||||||
|
_, err := parseSubTypeMessageQuestResult(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res`]")
|
||||||
|
err = setClientIdle(m.TGUserID64, m.Date)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setClientIdle")
|
||||||
|
case cacheObjSubType[`msg_job_gwithdraw_ack`]:
|
||||||
|
_, err := parseSubTypeMessageJobGWithdrawAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res`]")
|
||||||
|
case cacheObjSubType[`msg_bot_g_stock`]:
|
||||||
|
botGStock(m)
|
||||||
|
case cacheObjSubType[`msg_bot_shops`]:
|
||||||
|
botShops(m)
|
||||||
|
case cacheObjSubType[`msg_bot_craft_item`]:
|
||||||
|
botCraftItem(m, rule.re)
|
||||||
|
case cacheObjSubType[`msg_bot_craft_all`]:
|
||||||
|
botCraftAll(m, rule.re)
|
||||||
|
case cacheObjSubType[`msg_bot_get_stash`]:
|
||||||
|
botGetStash(m, rule.re)
|
||||||
|
case cacheObjSubType[`msg_tributes_stats_req`]:
|
||||||
|
case cacheObjSubType[`msg_tributes_stats_ack`]:
|
||||||
|
cwm, err := parseSubTypeMessageTributesStatsAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_tributes_stats_ack`]")
|
||||||
|
err = insertMsgTributesStats(cwm)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgTributesStats")
|
||||||
|
case cacheObjSubType[`msg_shop_main_req`]:
|
||||||
|
case cacheObjSubType[`msg_shop_main_ack`]:
|
||||||
|
cwm, err := parseSubTypeMessageShopMainAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_shop_main_ack`]")
|
||||||
|
err = insertMsgShopMainAck(cwm)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgShopMainAck")
|
||||||
|
case cacheObjSubType[`msg_bot_user_config`]:
|
||||||
|
botUserConfig(m)
|
||||||
|
case cacheObjSubType[`msg_bot_user_config_pillage_on`]:
|
||||||
|
botUserConfigPillage(m, true)
|
||||||
|
case cacheObjSubType[`msg_bot_user_config_pillage_off`]:
|
||||||
|
botUserConfigPillage(m, false)
|
||||||
|
case cacheObjSubType[`msg_bot_user_config_def_guild`]:
|
||||||
|
botUserConfigWartime(m, `/g_def`)
|
||||||
|
case cacheObjSubType[`msg_bot_user_config_def_castle`]:
|
||||||
|
botUserConfigWartime(m, `🛡Defend`)
|
||||||
|
case cacheObjSubType[`msg_bot_user_config_deposit_on`]:
|
||||||
|
botUserConfigDeposit(m, true)
|
||||||
|
case cacheObjSubType[`msg_bot_user_config_deposit_off`]:
|
||||||
|
botUserConfigDeposit(m, false)
|
||||||
|
case cacheObjSubType[`msg_bot_shutdown`]:
|
||||||
|
botShutdown()
|
||||||
|
case cacheObjSubType[`msg_bot_rage_up`]:
|
||||||
|
case cacheObjSubType[`msg_bot_peace_up`]:
|
||||||
|
case cacheObjSubType[`msg_bot_alch_all`]:
|
||||||
|
botAlchAll(m)
|
||||||
|
case cacheObjSubType[`msg_alch_stock_req`]:
|
||||||
|
case cacheObjSubType[`msg_alch_stock_ack`]:
|
||||||
|
_, err := parseSubTypeMessageAlchStockAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_alch_stock_ack`]")
|
||||||
|
case cacheObjSubType[`msg_skill_too_low`]:
|
||||||
|
default:
|
||||||
|
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID64, objId, m.Text)
|
||||||
}
|
}
|
||||||
|
muxCallbacks.Lock()
|
||||||
|
if mc1, mok1 := callbacks[m.TGUserID64]; mok1 {
|
||||||
|
if mc2, mok2 := mc1[rule.MsgTypeID64]; mok2 {
|
||||||
|
for j := range mc2 {
|
||||||
|
err := rescheduleJob(mc2[j], m.ObjID64, time.Now().UTC())
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : callbacks triggering")
|
||||||
|
}
|
||||||
|
mc1[rule.MsgTypeID64] = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if mc1, mok1 := callbacks[int64(bot.Me.ID)]; mok1 {
|
||||||
|
if mc2, mok2 := mc1[rule.MsgTypeID64]; mok2 {
|
||||||
|
for j := range mc2 {
|
||||||
|
err := rescheduleJob(mc2[j], m.ObjID64, time.Now().UTC())
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : callbacks triggering")
|
||||||
|
}
|
||||||
|
mc1[rule.MsgTypeID64] = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
muxCallbacks.Unlock()
|
||||||
}
|
}
|
||||||
muxCallbacks.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user