update static to map

This commit is contained in:
shoopea 2020-01-02 19:35:03 +08:00
parent b0e894221c
commit 80ffef4a66
6 changed files with 266 additions and 266 deletions

4
bot.go
View File

@ -287,7 +287,7 @@ func botMsgRescan(m *tb.Message) {
r := regexp.MustCompile("^[0-9]+$") r := regexp.MustCompile("^[0-9]+$")
if r.MatchString(m.Payload) { if r.MatchString(m.Payload) {
p := JobPayloadRescanMsg{ p := JobPayloadRescanMsg{
Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.id = %s AND o.obj_type_id = %d AND o.obj_sub_type_id = %d;", m.Payload, objTypeMessage, objSubTypeMessageUnknown), Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.id = %s AND o.obj_type_id = %d AND o.obj_sub_type_id = %d;", m.Payload, objTypeMessage, cacheObjSubType[`msg`]),
MsgID64: int64(m.ID), MsgID64: int64(m.ID),
ChatID64: m.Chat.ID, ChatID64: m.Chat.ID,
} }
@ -347,7 +347,7 @@ func botMsgRescanAll(m *tb.Message) {
return return
} }
p := JobPayloadRescanMsg{ p := JobPayloadRescanMsg{
Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.obj_type_id = %d AND o.obj_sub_type_id = %d ORDER BY id ASC;", objTypeMessage, objSubTypeMessageUnknown), Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.obj_type_id = %d AND o.obj_sub_type_id = %d ORDER BY id ASC;", objTypeMessage, cacheObjSubType[`msg`]),
MsgID64: int64(m.ID), MsgID64: int64(m.ID),
ChatID64: m.Chat.ID, ChatID64: m.Chat.ID,
} }

View File

@ -31,7 +31,7 @@ func cronSendWarReport() {
ChatID64: cfg.Bot.Reportchat, ChatID64: cfg.Bot.Reportchat,
} }
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err := createJobCallback(objSubTypeJobFwdMsg, c.TGUserID64, objSubTypeMessageReportAck, b, 1*time.Minute) err := createJobCallback(objSubTypeJobFwdMsg, c.TGUserID64, cacheObjSubType[`msg_report_ack`], b, 1*time.Minute)
logOnError(err, "cronSendWarReport : createJobCallback") logOnError(err, "cronSendWarReport : createJobCallback")
clientSendCWMsgDelay(c.TGUserID64, `/report`, 0) clientSendCWMsgDelay(c.TGUserID64, `/report`, 0)
} }
@ -46,7 +46,7 @@ func cronSetDef() {
if c.Active { if c.Active {
p := JobPayloadSetDef{} p := JobPayloadSetDef{}
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err := createJobCallback(objSubTypeJobSetDef, c.TGUserID64, objSubTypeMessageMeAck, b, 1*time.Minute) err := createJobCallback(objSubTypeJobSetDef, c.TGUserID64, cacheObjSubType[`msg_me_ack`], b, 1*time.Minute)
logOnError(err, "cronSetDef : createJobCallback") logOnError(err, "cronSetDef : createJobCallback")
clientSendCWMsgDelay(c.TGUserID64, `🏅Me`, 0) clientSendCWMsgDelay(c.TGUserID64, `🏅Me`, 0)
} }
@ -64,7 +64,7 @@ func cronGetHammerTime() {
clt.Mux.Unlock() clt.Mux.Unlock()
p := JobPayloadGetHammerTime{} p := JobPayloadGetHammerTime{}
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGetHammerTime, clt.TGUserID64, objSubTypeMessageTimeAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGetHammerTime, clt.TGUserID64, cacheObjSubType[`msg_time_ack`], b, 1*time.Minute)
logOnError(err, "cronGetHammerTime : createJobCallback") logOnError(err, "cronGetHammerTime : createJobCallback")
clientSendCWMsgDelay(clt.TGUserID64, `/time`, 0) clientSendCWMsgDelay(clt.TGUserID64, `/time`, 0)
} }

206
def.go
View File

@ -465,110 +465,110 @@ const (
objSubTypeUser = 101 objSubTypeUser = 101
objSubTypeGuild = 201 objSubTypeGuild = 201
objSubTypeMessageUnknown = 301 cacheObjSubType[`msg`] = 301
objSubTypeMessageWar = 302 // from Chat Wars Reports (not done) cacheObjSubType[`msg_war`] = 302 // from Chat Wars Reports (not done)
objSubTypeMessageMiniWar = 303 // FIXME DELETE objSubTypeMessageMiniWar = 303 // FIXME DELETE
objSubTypeMessageGuildWar = 304 // from Chat Wars Reports (not done) cacheObjSubType[`msg_guild_war`] = 304 // from Chat Wars Reports (not done)
objSubTypeMessageReportReq = 305 // /report (done) cacheObjSubType[`msg_report_req`] = 305 // /report (done)
objSubTypeMessageReportAck = 306 // result from /report (done) cacheObjSubType[`msg_report_ack`] = 306 // result from /report (done)
objSubTypeMessageGReportReq = 307 // /g_report (done) cacheObjSubType[`msg_g_report_req`] = 307 // /g_report (done)
objSubTypeMessageGReportAck = 308 // result from /g_report (not done) cacheObjSubType[`msg_g_report_ack`] = 308 // result from /g_report (not done)
objSubTypeMessageQuestResult = 309 // result from going to quest (not done) cacheObjSubType[`msg_quest_res`] = 309 // result from going to quest (not done)
objSubTypeMessageDuelFight = 310 // result from going to duel fight (done) cacheObjSubType[`msg_duel_fight`] = 310 // result from going to duel fight (done)
objSubTypeMessageHeroReq = 311 // /hero (done) cacheObjSubType[`msg_hero_req`] = 311 // /hero (done)
objSubTypeMessageHeroAck = 312 // result from /hero (not done) cacheObjSubType[`msg_hero_ack`] = 312 // result from /hero (not done)
objSubTypeMessageMeReq = 313 // 🏅Me (done) cacheObjSubType[`msg_me_req`] = 313 // 🏅Me (done)
objSubTypeMessageMeAck = 314 // result from 🏅Me (done) cacheObjSubType[`msg_me_ack`] = 314 // result from 🏅Me (done)
objSubTypeMessageInventoryReq = 315 // /inv (done) cacheObjSubType[`msg_inv_req`] = 315 // /inv (done)
objSubTypeMessageInventoryAck = 316 // result from /inv (not done) cacheObjSubType[`msg_inv_ack`] = 316 // result from /inv (not done)
objSubTypeMessagePillageInc = 317 // random incoming pillage (done) cacheObjSubType[`msg_pillage_inc`] = 317 // random incoming pillage (done)
objSubTypeMessagePillageGo = 318 // ack from /go (done) cacheObjSubType[`msg_pillage_go`] = 318 // ack from /go (done)
objSubTypeMessagePillageTimeout = 319 // ack from lack of /go (done) cacheObjSubType[`msg_pillage_timeout`] = 319 // ack from lack of /go (done)
objSubTypeMessagePillageWin = 320 // pillage successfully intercepted (done) cacheObjSubType[`msg_pillage_win`] = 320 // pillage successfully intercepted (done)
objSubTypeMessagePillageLoss = 321 // pillage not intercepted (done) cacheObjSubType[`msg_pillage_loss`] = 321 // pillage not intercepted (done)
objSubTypeMessageTributeInc = 322 // request for a /pledge (not done) cacheObjSubType[`msg_tribute_inc`] = 322 // request for a /pledge (not done)
objSubTypeMessageTributeAck = 323 // pledge accepted (not done) cacheObjSubType[`msg_tribute_ack`] = 323 // pledge accepted (not done)
objSubTypeMessageAuctionAnnounce = 324 // from Boris and Co, Ltd (done) cacheObjSubType[`msg_auction_announce`] = 324 // from Boris and Co, Ltd (done)
objSubTypeMessageAuctionUpdReq = 325 // /l_123456 msg (not done) cacheObjSubType[`msg_auction_upd_req`] = 325 // /l_123456 msg (not done)
objSubTypeMessageAuctionUpdAck = 326 // result from /l_123456 (not done) cacheObjSubType[`msg_auction_upd_ack`] = 326 // result from /l_123456 (not done)
objSubTypeMessageTimeAck = 327 // result from /time (done) cacheObjSubType[`msg_time_ack`] = 327 // result from /time (done)
objSubTypeMessageTimeReq = 328 // /time (done) cacheObjSubType[`msg_time_req`] = 328 // /time (done)
objSubTypeMessageGo = 329 // /go (done) cacheObjSubType[`msg_go`] = 329 // /go (done)
objSubTypeMessagePledge = 330 // /pledge (done) cacheObjSubType[`msg_pledge`] = 330 // /pledge (done)
objSubTypeMessageGoQuestReq = 331 // 🌲Forest or 🍄Swamp or ⛰Valley (not done) cacheObjSubType[`msg_go_quest_req`] = 331 // 🌲Forest or 🍄Swamp or ⛰Valley (not done)
objSubTypeMessageGoFastFight = 332 // ▶Fast fight (not done) cacheObjSubType[`msg_fast_fight`] = 332 // ▶Fast fight (not done)
objSubTypeMessageGoArena = 333 // 📯Arena (not done) cacheObjSubType[`msg_go_arena`] = 333 // 📯Arena (not done)
objSubTypeMessageTop = 334 // any /topXX (not done) cacheObjSubType[`msg_top`] = 334 // any /topXX (not done)
objSubTypeMessageMenu = 335 // main menu (not done) cacheObjSubType[`msg_menu`] = 335 // main menu (not done)
objSubTypeMessageBuyReq = 336 // /wtb_xx (done) cacheObjSubType[`msg_buy_req`] = 336 // /wtb_xx (done)
objSubTypeMessageSellReq = 337 // /wts_xx (done) cacheObjSubType[`msg_sell_req`] = 337 // /wts_xx (done)
objSubTypeMessageOrderbookReq = 338 // /t_xx (done) cacheObjSubType[`msg_orderbook_req`] = 338 // /t_xx (done)
objSubTypeMessageOrderbookAck = 339 // orderbook summary (not done) cacheObjSubType[`msg_orderbook_acl`] = 339 // orderbook summary (not done)
objSubTypeMessageWithdrawReq = 340 // /g_withdraw (done) cacheObjSubType[`msg_withdraw_req`] = 340 // /g_withdraw (done)
objSubTypeMessageWithdrawCode = 341 // code to receive (done) cacheObjSubType[`msg_withdraw_code`] = 341 // code to receive (done)
objSubTypeMessageWithdrawRcv = 342 // Withdraw "received" msg (done) cacheObjSubType[`msg_withdraw_rcv`] = 342 // Withdraw "received" msg (done)
objSubTypeMessageStockReq = 343 // /stock (done) cacheObjSubType[`msg_stock_req`] = 343 // /stock (done)
objSubTypeMessageStockAck = 344 // result from /stock (not done) cacheObjSubType[`msg_stock_ack`] = 344 // result from /stock (not done)
objSubTypeMessageMiscReq = 345 // /misc (done) cacheObjSubType[`msg_misc_req`] = 345 // /misc (done)
objSubTypeMessageMiscAck = 346 // result from /misc (not done) cacheObjSubType[`msg_misc_ack`] = 346 // result from /misc (not done)
objSubTypeMessageUnionWar = 347 // from Chat Wars Reports (not done) cacheObjSubType[`msg_union_war`] = 347 // from Chat Wars Reports (not done)
objSubTypeMessageTUReportReq = 348 // /tu_report (not done) cacheObjSubType[`msg_tureport_req`] = 348 // /tu_report (not done)
objSubTypeMessageTUReportAck = 349 // result from /tu_report (not done) cacheObjSubType[`msg_tureport_ack`] = 349 // result from /tu_report (not done)
objSubTypeMessageTimeout = 350 // generic timeout for action cacheObjSubType[`msg_timeout`] = 350 // generic timeout for action
objSubTypeMessageGoQuestAck = 351 // confirm quest destination/busyness (done) cacheObjSubType[`msg_go_quest_ack`] = 351 // confirm quest destination/busyness (done)
objSubTypeMessageGRolesReq = 352 // /g_roles (done) cacheObjSubType[`msg_groles_req`] = 352 // /g_roles (done)
objSubTypeMessageGRolesAck = 353 // result from /g_roles (done) cacheObjSubType[`msg_groles_ack`] = 353 // result from /g_roles (done)
objSubTypeMessageGStockResReq = 354 // /g_stock_res (done) cacheObjSubType[`msg_gstock_res_req`] = 354 // /g_stock_res (done)
objSubTypeMessageGStockAlchReq = 355 // /g_stock_alch (done) cacheObjSubType[`msg_gstock_alch_req`] = 355 // /g_stock_alch (done)
objSubTypeMessageGStockMiscReq = 356 // /g_stock_misc (done) cacheObjSubType[`msg_gstock_misc_req`] = 356 // /g_stock_misc (done)
objSubTypeMessageGStockRecReq = 357 // /g_stock_rec (done) cacheObjSubType[`msg_gstock_rec_req`] = 357 // /g_stock_rec (done)
objSubTypeMessageGStockPartReq = 358 // /g_stock_parts (done) cacheObjSubType[`msg_gstock_part_req`] = 358 // /g_stock_parts (done)
objSubTypeMessageGStockOthReq = 359 // /g_stock_other (done) cacheObjSubType[`msg_gstock_oth_req`] = 359 // /g_stock_other (done)
objSubTypeMessageGStockAnyAck = 360 // result from any /g_stock_xxx (done) cacheObjSubType[`msg_gstock_any_ack`] = 360 // result from any /g_stock_xxx (done)
objSubTypeMessageGStockReq = 361 // /g_stock (done) cacheObjSubType[`msg_gstock_req`] = 361 // /g_stock (done)
objSubTypeMessageGStockAck = 362 // result from /g_stock (done) cacheObjSubType[`msg_gstock_ack`] = 362 // result from /g_stock (done)
objSubTypeMessageBusy = 363 // too busy now cacheObjSubType[`msg_busy`] = 363 // too busy now
objSubTypeMessageResStockReq = 364 // 📦Resources or /stock (done) cacheObjSubType[`msg_res_stock_req`] = 364 // 📦Resources or /stock (done)
objSubTypeMessageAlchStockReq = 365 // ⚗Alchemy (done) cacheObjSubType[`msg_alch_stock_req`] = 365 // ⚗Alchemy (done)
objSubTypeMessageMiscStockReq = 366 // 🗃Misc or /misc (done) cacheObjSubType[`msg_misc_stock_req`] = 366 // 🗃Misc or /misc (done)
objSubTypeMessageEquipStockReq = 367 // 🏷Equipment (done) cacheObjSubType[`msg_equip_stock_req`] = 367 // 🏷Equipment (done)
objSubTypeMessageCraftStockReq = 368 // ⚒Crafting (done) cacheObjSubType[`msg_craft_stock_req`] = 368 // ⚒Crafting (done)
objSubTypeMessageStockEmpty = 369 // [empty] (done) cacheObjSubType[`msg_stock_empty`] = 369 // [empty] (done)
objSubTypeMessageStockAnyAck = 370 // list of stock (done) cacheObjSubType[`msg_stock_any_ack`] = 370 // list of stock (done)
objSubTypeMessageGDepositReq = 371 // /g_deposit xx y (done) cacheObjSubType[`msg_g_deposit_req`] = 371 // /g_deposit xx y (done)
objSubTypeMessageGDepositAck = 372 // Deposited successfully: xx (y) (done) cacheObjSubType[`msg_g_deposit_ack`] = 372 // Deposited successfully: xx (y) (done)
objSubTypeMessageAttackReq = 373 // Attack (done) cacheObjSubType[`msg_castle_attack_req`] = 373 // Attack (done)
objSubTypeMessageAttackAck = 374 // Read for attack, select target (done) cacheObjSubType[`msg_castle_attack_ack`] = 374 // Read for attack, select target (done)
objSubTypeMessageAttackTargetReq = 375 // Castle selection (done) cacheObjSubType[`msg_castle_target_req`] = 375 // Castle selection (done)
objSubTypeMessageAttackTargetAck = 376 // Castle confirmation (done) cacheObjSubType[`msg_castle_target_ack`] = 376 // Castle confirmation (done)
objSubTypeMessageDefendReq = 377 // Defend (done) cacheObjSubType[`msg_castle_def_req`] = 377 // Defend (done)
objSubTypeMessageDefendAck = 378 // Defend confirmation (done) cacheObjSubType[`msg_castle_def_ack`] = 378 // Defend confirmation (done)
objSubTypeMessageBack = 379 // Back (done) cacheObjSubType[`msg_back`] = 379 // Back (done)
objSubTypeMessageCastleReq = 380 // Castle (done) cacheObjSubType[`msg_castle_req`] = 380 // Castle (done)
objSubTypeMessageCastleAck = 381 // Castle msg (not done) cacheObjSubType[`msg_castle_ack`] = 381 // Castle msg (not done)
objSubTypeMessageExchangeReq = 382 // ⚖Exchange (done) cacheObjSubType[`msg_exchange_req`] = 382 // ⚖Exchange (done)
objSubTypeMessageExchangeAck = 383 // List of deals (done) cacheObjSubType[`msg_exchange_ack`] = 383 // List of deals (done)
objSubTypeMessageEquipGearReq = 384 // /on_item (done) cacheObjSubType[`msg_equip_req`] = 384 // /on_item (done)
objSubTypeMessageEquipGearAck = 385 // Item equipped (done) cacheObjSubType[`msg_equip_ack`] = 385 // Item equipped (done)
objSubTypeMessageUnequipGearReq = 386 // /off_item (done) cacheObjSubType[`msg_unequip_req`] = 386 // /off_item (done)
objSubTypeMessageUnequipGearAck = 387 // Item unequipped (done) cacheObjSubType[`msg_unequip_ack`] = 387 // Item unequipped (done)
objSubTypeMessageNoStamina = 388 // Not enough stamina. (done) cacheObjSubType[`msg_no_stamina`] = 388 // Not enough stamina. (done)
objSubTypeMessageOrderbookSearch = 389 // /t <something> cacheObjSubType[`msg_orderbook_search`] = 389 // /t <something>
objSubTypeMessageQuestReq = 390 // quest cacheObjSubType[`msg_quest_req`] = 390 // quest
objSubTypeMessageQuestAck = 391 // forest/swamp/valley/arena cacheObjSubType[`msg_quest_ack`] = 391 // forest/swamp/valley/arena
objSubTypeMessageBattle = 392 // wind is howling cacheObjSubType[`msg_battle`] = 392 // wind is howling
objSubTypeMessageOrderCancelReq = 393 // /rm_xxx cacheObjSubType[`msg_order_cancel_req`] = 393 // /rm_xxx
objSubTypeMessageOrderCancelAck = 394 // Cancelling order cacheObjSubType[`msg_order_cancel_ack`] = 394 // Cancelling order
objSubTypeMessageStaminaRestored = 395 // Stamina Restored cacheObjSubType[`msg_stamina_restored`] = 395 // Stamina Restored
objSubTypeMessageTopReq = 396 cacheObjSubType[`msg_top`]Req = 396
objSubTypeMessageQuestResultAmbush = 397 // result from going to quest with ambush (not done) cacheObjSubType[`msg_quest_res_ambush`] = 397 // result from going to quest with ambush (not done)
objSubTypeMessageHealUpFirst = 398 // you should heal up first (done) cacheObjSubType[`msg_heal_up`] = 398 // you should heal up first (done)
objSubTypeMessageArenaFightAck = 399 // thirsty for blood ... (done) cacheObjSubType[`msg_arena_fight_ack`] = 399 // thirsty for blood ... (done)
objSubTypeMessageGoArenaAck = 400 // Welcome to Arena! (done) cacheObjSubType[`msg_go_arena`]Ack = 400 // Welcome to Arena! (done)
objSubTypeMessageWithdrawNAck = 401 // not enought items (done) cacheObjSubType[`msg_withdraw_nack`] = 401 // not enought items (done)
objSubTypeMessagePillageDefeat = 402 // You tried stopping (done) cacheObjSubType[`msg_pillage_defeat`] = 402 // You tried stopping (done)
objSubTypeMessageLevelUpReq = 403 // /level_up cacheObjSubType[`msg_level_up_req`] = 403 // /level_up
objSubTypeMessageLevelUpAck = 404 cacheObjSubType[`msg_level_up_ack`] = 404
objSubTypeJobPillage = 601 objSubTypeJobPillage = 601
objSubTypeJobTribute = 602 objSubTypeJobTribute = 602
objSubTypeJobStatus = 603 objSubTypeJobStatus = 603

94
job.go
View File

@ -344,17 +344,17 @@ func jobPillage(j Job) {
AND omx.user_id = oj.user_id AND omx.user_id = oj.user_id
AND omx.sender_user_id = ` + strconv.Itoa(userID64ChtWrsBot) + ` AND omx.sender_user_id = ` + strconv.Itoa(userID64ChtWrsBot) + `
AND omx.obj_id = ox.id AND omx.obj_id = ox.id
AND ox.obj_sub_type_id in (` + strconv.Itoa(objSubTypeMessagePillageGo) + AND ox.obj_sub_type_id in (` + strconv.Itoa(cacheObjSubType[`msg_pillage_go`]) +
`, ` + strconv.Itoa(objSubTypeMessagePillageTimeout) + `, ` + strconv.Itoa(cacheObjSubType[`msg_pillage_timeout`]) +
`, ` + strconv.Itoa(objSubTypeMessagePillageLoss) + `, ` + strconv.Itoa(cacheObjSubType[`msg_pillage_loss`]) +
`, ` + strconv.Itoa(objSubTypeMessagePillageWin) + `) `, ` + strconv.Itoa(cacheObjSubType[`msg_pillage_win`]) + `)
AND op.id = ` + strconv.FormatInt(r.ObjID64, 10) + ` AND op.id = ` + strconv.FormatInt(r.ObjID64, 10) + `
AND omp.obj_id = op.id AND omp.obj_id = op.id
AND omx.date between omp.date AND ADDTIME(omp.date, '0 0:3:30.000000') AND omx.date between omp.date AND ADDTIME(omp.date, '0 0:3:30.000000')
ORDER BY CASE ox.obj_sub_type_id WHEN ` + strconv.Itoa(objSubTypeMessagePillageWin) + ` THEN 0 ORDER BY CASE ox.obj_sub_type_id WHEN ` + strconv.Itoa(cacheObjSubType[`msg_pillage_win`]) + ` THEN 0
WHEN ` + strconv.Itoa(objSubTypeMessagePillageLoss) + ` THEN 1 WHEN ` + strconv.Itoa(cacheObjSubType[`msg_pillage_loss`]) + ` THEN 1
WHEN ` + strconv.Itoa(objSubTypeMessagePillageTimeout) + ` THEN 2 WHEN ` + strconv.Itoa(cacheObjSubType[`msg_pillage_timeout`]) + ` THEN 2
WHEN ` + strconv.Itoa(objSubTypeMessagePillageGo) + ` THEN 3 WHEN ` + strconv.Itoa(cacheObjSubType[`msg_pillage_go`]) + ` THEN 3
ELSE 4 END ASC ELSE 4 END ASC
LIMIT 1;`) LIMIT 1;`)
@ -367,34 +367,34 @@ func jobPillage(j Job) {
TGCmdQueue <- s TGCmdQueue <- s
} else if len(ids) == 1 { // we've got a match, job is done whether we prevented the pillage or not } else if len(ids) == 1 { // we've got a match, job is done whether we prevented the pillage or not
m, err := getObjMsg(ids[0]) m, err := getObjMsg(ids[0])
logOnError(err, "jobPillage : getMsg(objSubTypeMessagePillageGo, objSubTypeMessagePillageTimeout)") logOnError(err, "jobPillage : getMsg(cacheObjSubType[`msg_pillage_go`], cacheObjSubType[`msg_pillage_timeout`])")
if err == nil { if err == nil {
if m.Date.Add(60 * time.Second).After(time.Now().UTC()) { if m.Date.Add(60 * time.Second).After(time.Now().UTC()) {
msgTypeID64, err := getObjSubTypeId(ids[0]) msgTypeID64, err := getObjSubTypeId(ids[0])
logOnError(err, "jobPillage : getObjSubTypeId") logOnError(err, "jobPillage : getObjSubTypeId")
if err == nil { if err == nil {
if msgTypeID64 == objSubTypeMessagePillageGo { if msgTypeID64 == cacheObjSubType[`msg_pillage_go`] {
s := TGCommand{ s := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: fmt.Sprintf("We avoided a pillage (%s)", m.Date.Format(time.RFC3339)), Text: fmt.Sprintf("We avoided a pillage (%s)", m.Date.Format(time.RFC3339)),
ToUserID64: j.UserID64, ToUserID64: j.UserID64,
} }
TGCmdQueue <- s TGCmdQueue <- s
} else if msgTypeID64 == objSubTypeMessagePillageWin { } else if msgTypeID64 == cacheObjSubType[`msg_pillage_win`] {
s := TGCommand{ s := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: fmt.Sprintf("We avoided a pillage (%s))", m.Date.Format(time.RFC3339)), Text: fmt.Sprintf("We avoided a pillage (%s))", m.Date.Format(time.RFC3339)),
ToUserID64: j.UserID64, ToUserID64: j.UserID64,
} }
TGCmdQueue <- s TGCmdQueue <- s
} else if msgTypeID64 == objSubTypeMessagePillageLoss { } else if msgTypeID64 == cacheObjSubType[`msg_pillage_loss`] {
s := TGCommand{ s := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: fmt.Sprintf("We got pillaged (%s)", m.Date.Format(time.RFC3339)), Text: fmt.Sprintf("We got pillaged (%s)", m.Date.Format(time.RFC3339)),
ToUserID64: j.UserID64, ToUserID64: j.UserID64,
} }
TGCmdQueue <- s TGCmdQueue <- s
} else if msgTypeID64 == objSubTypeMessagePillageTimeout { } else if msgTypeID64 == cacheObjSubType[`msg_pillage_timeout`] {
s := TGCommand{ s := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: fmt.Sprintf("We got pillaged (%s)", m.Date.Format(time.RFC3339)), Text: fmt.Sprintf("We got pillaged (%s)", m.Date.Format(time.RFC3339)),
@ -445,12 +445,12 @@ func jobPillage(j Job) {
and omx.user_id = oj.user_id and omx.user_id = oj.user_id
and omx.sender_user_id = oj.user_id and omx.sender_user_id = oj.user_id
and omx.obj_id = ox.id and omx.obj_id = ox.id
and ox.obj_sub_type_id =` + strconv.Itoa(objSubTypeMessageGo) + ` and ox.obj_sub_type_id =` + strconv.Itoa(cacheObjSubType[`msg_go`]) + `
and omx.date between addtime(oj.schedule, '-30') and oj.schedule;`) and omx.date between addtime(oj.schedule, '-30') and oj.schedule;`)
if len(ids) > 0 { // we did, so we reschedule the job to check the outcome and wait if len(ids) > 0 { // we did, so we reschedule the job to check the outcome and wait
m, err := getObjMsg(ids[0]) m, err := getObjMsg(ids[0])
logOnError(err, "jobPillage : getMsg(objSubTypeMessageGo)") logOnError(err, "jobPillage : getMsg(cacheObjSubType[`msg_go`])")
if err == nil { if err == nil {
s := TGCommand{ s := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
@ -460,7 +460,7 @@ func jobPillage(j Job) {
TGCmdQueue <- s TGCmdQueue <- s
} }
err = rescheduleJob(j.ID64, j.Trigger, time.Now().Add(30*time.Second).UTC()) err = rescheduleJob(j.ID64, j.Trigger, time.Now().Add(30*time.Second).UTC())
logOnError(err, "jobPillage : rescheduleJob(objSubTypeMessageGo)") logOnError(err, "jobPillage : rescheduleJob(cacheObjSubType[`msg_go`])")
} else { //no /go in the last 30 sec so we go ahead, send one and reschedule to check again in 25sec } else { //no /go in the last 30 sec so we go ahead, send one and reschedule to check again in 25sec
clientSendCWMsg(j.UserID64, "/go") clientSendCWMsg(j.UserID64, "/go")
err = rescheduleJob(j.ID64, j.Trigger, time.Now().Add(30*time.Second).UTC()) err = rescheduleJob(j.ID64, j.Trigger, time.Now().Add(30*time.Second).UTC())
@ -719,9 +719,9 @@ func jobGStock(j Job) {
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
jobID64, err := createJob(objSubTypeJobGStock, objJobPriority, j.UserID64, 0, time.Unix(maxUnixTimestamp, 0).UTC(), b) jobID64, err := createJob(objSubTypeJobGStock, objJobPriority, j.UserID64, 0, time.Unix(maxUnixTimestamp, 0).UTC(), b)
logOnError(err, "jobGStock : createJob") logOnError(err, "jobGStock : createJob")
setJobCallback(jobID64, j.UserID64, objSubTypeMessageGStockAnyAck) setJobCallback(jobID64, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`])
setJobCallback(jobID64, j.UserID64, objSubTypeMessageBusy) setJobCallback(jobID64, j.UserID64, cacheObjSubType[`msg_busy`])
setJobCallback(jobID64, j.UserID64, objSubTypeMessageBattle) setJobCallback(jobID64, j.UserID64, cacheObjSubType[`msg_battle`])
err = setJobTimeout(jobID64, 1*time.Minute) err = setJobTimeout(jobID64, 1*time.Minute)
logOnError(err, "jobGStock : setJobTimeout") logOnError(err, "jobGStock : setJobTimeout")
clientSendCWMsg(j.UserID64, "/g_stock_res") clientSendCWMsg(j.UserID64, "/g_stock_res")
@ -730,17 +730,17 @@ func jobGStock(j Job) {
logOnError(err, "jobGStock : getObjMsg msg") logOnError(err, "jobGStock : getObjMsg msg")
rule, err := getMsgParsingRule(msg) rule, err := getMsgParsingRule(msg)
logOnError(err, "jobGStock : getMsgParsingRule") logOnError(err, "jobGStock : getMsgParsingRule")
if rule.MsgTypeID64 == objSubTypeMessageGStockAnyAck { if rule.MsgTypeID64 == cacheObjSubType[`msg_gstock_any_ack`] {
cwm, err := parseSubTypeMessageGStockAnyAck(msg, rule.re) cwm, err := parseSubTypeMessageGStockAnyAck(msg, rule.re)
for _, v := range cwm.Stock { for _, v := range cwm.Stock {
p.Stock = append(p.Stock, v) p.Stock = append(p.Stock, v)
} }
p.Progress = 2 p.Progress = 2
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, objSubTypeMessageGStockAnyAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_alch") clientSendCWMsg(j.UserID64, "/g_stock_alch")
} else if rule.MsgTypeID64 == objSubTypeMessageBusy || rule.MsgTypeID64 == objSubTypeMessageBattle { } else if rule.MsgTypeID64 == cacheObjSubType[`msg_busy`] || rule.MsgTypeID64 == cacheObjSubType[`msg_battle`] {
m := TGCommand{ m := TGCommand{
Type: commandReplyMsg, Type: commandReplyMsg,
Text: "Busy, please retry later.", Text: "Busy, please retry later.",
@ -761,7 +761,7 @@ func jobGStock(j Job) {
} }
p.Progress = 3 p.Progress = 3
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, objSubTypeMessageGStockAnyAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_misc") clientSendCWMsg(j.UserID64, "/g_stock_misc")
case 3: // send /g_stock_rec case 3: // send /g_stock_rec
@ -775,7 +775,7 @@ func jobGStock(j Job) {
} }
p.Progress = 4 p.Progress = 4
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, objSubTypeMessageGStockAnyAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_rec") clientSendCWMsg(j.UserID64, "/g_stock_rec")
case 4: // send /g_stock_parts case 4: // send /g_stock_parts
@ -789,7 +789,7 @@ func jobGStock(j Job) {
} }
p.Progress = 5 p.Progress = 5
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, objSubTypeMessageGStockAnyAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_parts") clientSendCWMsg(j.UserID64, "/g_stock_parts")
case 5: // send /g_stock_other case 5: // send /g_stock_other
@ -803,7 +803,7 @@ func jobGStock(j Job) {
} }
p.Progress = 6 p.Progress = 6
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, objSubTypeMessageGStockAnyAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_other") clientSendCWMsg(j.UserID64, "/g_stock_other")
case 6: // collate everything and reply case 6: // collate everything and reply
@ -894,7 +894,7 @@ func jobGDepositForward(j Job) {
//log.Printf("jobGDepositForward : found (%d / %d), expected (%d / %d).\n", cwm.ItemID64, cwm.Quantity, p.ItemID64, p.Quantity) //log.Printf("jobGDepositForward : found (%d / %d), expected (%d / %d).\n", cwm.ItemID64, cwm.Quantity, p.ItemID64, p.Quantity)
err = rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) err = rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC())
logOnError(err, "jobGDepositForward : rescheduleJob") logOnError(err, "jobGDepositForward : rescheduleJob")
setJobCallback(j.ID64, j.UserID64, objSubTypeMessageGDepositReq) setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_g_deposit_req`])
} }
return return
@ -941,9 +941,9 @@ func jobGDeposit(j Job) {
if res { if res {
clientSendCWMsgDelay(p.ChatID64, `📦Resources`, delay) clientSendCWMsgDelay(p.ChatID64, `📦Resources`, delay)
p.Status = objSubTypeMessageStockAck p.Status = cacheObjSubType[`msg_stock_ack`]
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageStockAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_stock_ack`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
@ -951,7 +951,7 @@ func jobGDeposit(j Job) {
clientSendCWMsgDelay(p.ChatID64, `Alchemy`, delay) clientSendCWMsgDelay(p.ChatID64, `Alchemy`, delay)
p.Status = 1 // FIXME UPDATE WITH PROPER TYPE p.Status = 1 // FIXME UPDATE WITH PROPER TYPE
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
@ -959,15 +959,15 @@ func jobGDeposit(j Job) {
clientSendCWMsgDelay(p.ChatID64, `🗃Misc`, delay) clientSendCWMsgDelay(p.ChatID64, `🗃Misc`, delay)
p.Status = 1 // FIXME UPDATE WITH PROPER TYPE p.Status = 1 // FIXME UPDATE WITH PROPER TYPE
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
if craft { if craft {
clientSendCWMsgDelay(p.ChatID64, `⚒Crafting`, delay) clientSendCWMsgDelay(p.ChatID64, `⚒Crafting`, delay)
p.Status = objSubTypeMessageStockAnyAck p.Status = cacheObjSubType[`msg_stock_any_ack`]
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageStockAnyAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_stock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
@ -975,17 +975,17 @@ func jobGDeposit(j Job) {
clientSendCWMsgDelay(p.ChatID64, `🏷Equipment`, delay) clientSendCWMsgDelay(p.ChatID64, `🏷Equipment`, delay)
p.Status = 1 // FIXME UPDATE WITH PROPER TYPE p.Status = 1 // FIXME UPDATE WITH PROPER TYPE
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, 1*time.Minute) err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
return return
} else if p.Status == 1 { /* handle that one resource from the objSubTypeMessageOrderbookAck msg */ } else if p.Status == 1 { /* handle that one resource from the cacheObjSubType[`msg_orderbook_acl`] msg */
log.Printf("jobGDeposit : 1 : %d.\n", j.Trigger) log.Printf("jobGDeposit : 1 : %d.\n", j.Trigger)
} else if p.Status == objSubTypeMessageStockAck { } else if p.Status == cacheObjSubType[`msg_stock_ack`] {
//log.Printf("jobGDeposit : objSubTypeMessageStockAck : %d.\n", j.Trigger) //log.Printf("jobGDeposit : cacheObjSubType[`msg_stock_ack`] : %d.\n", j.Trigger)
msg, err := getObjMsg(j.Trigger) msg, err := getObjMsg(j.Trigger)
logOnError(err, "jobGDeposit : getObjMsg") logOnError(err, "jobGDeposit : getObjMsg")
rule, err := getMsgParsingRule(msg) rule, err := getMsgParsingRule(msg)
@ -994,7 +994,7 @@ func jobGDeposit(j Job) {
for stockIdx := range cwm.Stock { for stockIdx := range cwm.Stock {
for resIdx := range p.ResObjID64 { for resIdx := range p.ResObjID64 {
if cwm.Stock[stockIdx].ItemID64 == p.ResObjID64[resIdx] { if cwm.Stock[stockIdx].ItemID64 == p.ResObjID64[resIdx] {
//log.Printf("jobGDeposit : objSubTypeMessageStockAck : Matching ItemID %d (%d).\n", p.ResObjID64[resIdx], cwm.Stock[stockIdx].Quantity) //log.Printf("jobGDeposit : cacheObjSubType[`msg_stock_ack`] : Matching ItemID %d (%d).\n", p.ResObjID64[resIdx], cwm.Stock[stockIdx].Quantity)
item, _ := getObjItem(p.ResObjID64[resIdx]) item, _ := getObjItem(p.ResObjID64[resIdx])
clientSendCWMsg(p.ChatID64, fmt.Sprintf("/g_deposit %s %d", item.Code, cwm.Stock[stockIdx].Quantity)) clientSendCWMsg(p.ChatID64, fmt.Sprintf("/g_deposit %s %d", item.Code, cwm.Stock[stockIdx].Quantity))
p2 := JobPayloadGDepositForward{ p2 := JobPayloadGDepositForward{
@ -1002,12 +1002,12 @@ func jobGDeposit(j Job) {
Quantity: cwm.Stock[stockIdx].Quantity, Quantity: cwm.Stock[stockIdx].Quantity,
} }
b2, _ := json.Marshal(p2) b2, _ := json.Marshal(p2)
err = createJobCallback(objSubTypeJobGDepositForward, j.UserID64, objSubTypeMessageGDepositReq, b2, time.Duration(1*time.Minute)) err = createJobCallback(objSubTypeJobGDepositForward, j.UserID64, cacheObjSubType[`msg_g_deposit_req`], b2, time.Duration(1*time.Minute))
} }
} }
} }
} else if p.Status == objSubTypeMessageStockAnyAck { } else if p.Status == cacheObjSubType[`msg_stock_any_ack`] {
log.Printf("jobGDeposit : objSubTypeMessageStockAnyAck : %d.\n", j.Trigger) log.Printf("jobGDeposit : cacheObjSubType[`msg_stock_any_ack`] : %d.\n", j.Trigger)
msg, err := getObjMsg(j.Trigger) msg, err := getObjMsg(j.Trigger)
logOnError(err, "jobGDeposit : getObjMsg") logOnError(err, "jobGDeposit : getObjMsg")
rule, err := getMsgParsingRule(msg) rule, err := getMsgParsingRule(msg)
@ -1016,7 +1016,7 @@ func jobGDeposit(j Job) {
for stockIdx := range cwm.Stock { for stockIdx := range cwm.Stock {
for resIdx := range p.ResObjID64 { for resIdx := range p.ResObjID64 {
if cwm.Stock[stockIdx].ItemID64 == p.ResObjID64[resIdx] { if cwm.Stock[stockIdx].ItemID64 == p.ResObjID64[resIdx] {
log.Printf("jobGDeposit : objSubTypeMessageStockAnyAck : Matching ItemID %d (%d).\n", p.ResObjID64[resIdx], cwm.Stock[stockIdx].Quantity) log.Printf("jobGDeposit : cacheObjSubType[`msg_stock_any_ack`] : Matching ItemID %d (%d).\n", p.ResObjID64[resIdx], cwm.Stock[stockIdx].Quantity)
item, _ := getObjItem(p.ResObjID64[resIdx]) item, _ := getObjItem(p.ResObjID64[resIdx])
clientSendCWMsg(p.ChatID64, fmt.Sprintf("/g_deposit %s %d", item.Code, cwm.Stock[stockIdx].Quantity)) clientSendCWMsg(p.ChatID64, fmt.Sprintf("/g_deposit %s %d", item.Code, cwm.Stock[stockIdx].Quantity))
p2 := JobPayloadGDepositForward{ p2 := JobPayloadGDepositForward{
@ -1024,7 +1024,7 @@ func jobGDeposit(j Job) {
Quantity: cwm.Stock[stockIdx].Quantity, Quantity: cwm.Stock[stockIdx].Quantity,
} }
b2, _ := json.Marshal(p2) b2, _ := json.Marshal(p2)
err = createJobCallback(objSubTypeJobGDepositForward, j.UserID64, objSubTypeMessageGDepositReq, b2, time.Duration(1*time.Minute)) err = createJobCallback(objSubTypeJobGDepositForward, j.UserID64, cacheObjSubType[`msg_g_deposit_req`], b2, time.Duration(1*time.Minute))
} }
} }
} }
@ -1055,13 +1055,13 @@ func jobVaultItemStatus(j Job) {
FROM obj_msg_vault_v omv FROM obj_msg_vault_v omv
WHERE omv.user_id = x.user_id WHERE omv.user_id = x.user_id
AND omv.item_id = x.item_id AND omv.item_id = x.item_id
AND omv.msg_type_id = ` + strconv.Itoa(objSubTypeMessageGDepositAck) + ` AND omv.msg_type_id = ` + strconv.Itoa(cacheObjSubType[`msg_g_deposit_ack`]) + `
AND omv.chat_id = x.chat_id) deposit AND omv.chat_id = x.chat_id) deposit
,(SELECT COALESCE(SUM(omv.quantity), 0) ,(SELECT COALESCE(SUM(omv.quantity), 0)
FROM obj_msg_vault_v omv FROM obj_msg_vault_v omv
WHERE omv.user_id = x.user_id WHERE omv.user_id = x.user_id
AND omv.item_id = x.item_id AND omv.item_id = x.item_id
AND omv.msg_type_id = ` + strconv.Itoa(objSubTypeMessageWithdrawRcv) + ` AND omv.msg_type_id = ` + strconv.Itoa(cacheObjSubType[`msg_withdraw_rcv`]) + `
AND omv.chat_id = x.chat_id) withdraw AND omv.chat_id = x.chat_id) withdraw
FROM (SELECT DISTINCT FROM (SELECT DISTINCT
omv.user_id omv.user_id
@ -1167,13 +1167,13 @@ func jobVaultUserStatus(j Job) {
FROM obj_msg_vault_v omv FROM obj_msg_vault_v omv
WHERE omv.user_id = x.user_id WHERE omv.user_id = x.user_id
AND omv.item_id = x.item_id AND omv.item_id = x.item_id
AND omv.msg_type_id = ` + strconv.Itoa(objSubTypeMessageGDepositAck) + ` AND omv.msg_type_id = ` + strconv.Itoa(cacheObjSubType[`msg_g_deposit_ack`]) + `
AND omv.chat_id = x.chat_id) deposit AND omv.chat_id = x.chat_id) deposit
,(SELECT COALESCE(SUM(omv.quantity), 0) ,(SELECT COALESCE(SUM(omv.quantity), 0)
FROM obj_msg_vault_v omv FROM obj_msg_vault_v omv
WHERE omv.user_id = x.user_id WHERE omv.user_id = x.user_id
AND omv.item_id = x.item_id AND omv.item_id = x.item_id
AND omv.msg_type_id = ` + strconv.Itoa(objSubTypeMessageWithdrawRcv) + ` AND omv.msg_type_id = ` + strconv.Itoa(cacheObjSubType[`msg_withdraw_rcv`]) + `
AND omv.chat_id = x.chat_id) withdraw AND omv.chat_id = x.chat_id) withdraw
FROM (SELECT DISTINCT FROM (SELECT DISTINCT
omv.user_id omv.user_id

6
obj.go
View File

@ -232,7 +232,7 @@ func addObjMsg(msgID64 int64, msgChatID64 int64, msgTGUserID64 int64, msgTGSende
} }
res, err := tx.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id) res, err := tx.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
VALUES (` + strconv.Itoa(objTypeMessage) + `,` + strconv.Itoa(objSubTypeMessageUnknown) + `);`) VALUES (` + strconv.Itoa(objTypeMessage) + `,` + strconv.Itoa(cacheObjSubType[`msg`]) + `);`)
if err != nil { if err != nil {
err2 := tx.Rollback() err2 := tx.Rollback()
logOnError(err2, "addObjMsg : rollback insert obj") logOnError(err2, "addObjMsg : rollback insert obj")
@ -320,8 +320,8 @@ func delObj(objId int64) error {
return err return err
} }
if objSubTypeId != objSubTypeMessageAuctionAnnounce { if objSubTypeId != cacheObjSubType[`msg_auction_announce`] {
return errors.New("Can only delete objSubTypeMessageAuctionAnnounce.") return errors.New("Can only delete cacheObjSubType[`msg_auction_announce`].")
} }
cacheObjMsg.Delete(objId) // better delete from cache before, worst case we reload after cacheObjMsg.Delete(objId) // better delete from cache before, worst case we reload after

216
sql.go
View File

@ -457,109 +457,109 @@ func initDB() {
_, err = db.Exec(`INSERT INTO code_obj_sub_type (id, intl_id, name, obj_type_id) _, err = db.Exec(`INSERT INTO code_obj_sub_type (id, intl_id, name, obj_type_id)
VALUES (` + strconv.Itoa(objSubTypeUser) + `, "user", "User", ` + strconv.Itoa(objTypeUser) + `) VALUES (` + strconv.Itoa(objSubTypeUser) + `, "user", "User", ` + strconv.Itoa(objTypeUser) + `)
,(` + strconv.Itoa(objSubTypeGuild) + `, "guild", "Guild", ` + strconv.Itoa(objTypeGuild) + `) ,(` + strconv.Itoa(objSubTypeGuild) + `, "guild", "Guild", ` + strconv.Itoa(objTypeGuild) + `)
,(` + strconv.Itoa(objSubTypeMessageUnknown) + `, "unknown", "Unknown", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg`]) + `, "unknown", "Unknown", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageWar) + `, "war", "War report", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_war`]) + `, "war", "War report", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGuildWar) + `, "guild_war", "Guilds war report", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_guild_war`]) + `, "guild_war", "Guilds war report", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageReportReq) + `, "report_req", "Player war report request", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_report_req`]) + `, "report_req", "Player war report request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageReportAck) + `, "report_ack", "Player war report ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_report_ack`]) + `, "report_ack", "Player war report ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGReportReq) + `, "g_report_req", "Player guilds war report request", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_g_report_req`]) + `, "g_report_req", "Player guilds war report request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGReportAck) + `, "g_report_ack", "Player guilds war report ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_g_report_ack`]) + `, "g_report_ack", "Player guilds war report ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "quest_res", "Quest result", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_quest_res`]) + `, "quest_res", "Quest result", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageQuestResultAmbush) + `, "quest_res_ambush", "Quest result with Ambush", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_quest_res_ambush`]) + `, "quest_res_ambush", "Quest result with Ambush", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageDuelFight) + `, "duel_fight", "Duel fight result", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_duel_fight`]) + `, "duel_fight", "Duel fight result", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageHeroReq) + `, "hero_req", "Hero summary request", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_hero_req`]) + `, "hero_req", "Hero summary request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageHeroAck) + `, "hero_ack", "Hero summary ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_hero_ack`]) + `, "hero_ack", "Hero summary ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMeReq) + `, "me_req", "Hero short summary request", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_me_req`]) + `, "me_req", "Hero short summary request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMeAck) + `, "me_ack", "Hero short summary ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_me_ack`]) + `, "me_ack", "Hero short summary ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageInventoryReq) + `, "inv_req", "Inventory request", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_inv_req`]) + `, "inv_req", "Inventory request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageInventoryAck) + `, "inv_ack", "Inventory ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_inv_ack`]) + `, "inv_ack", "Inventory ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "pillage_inc", "Pillage incoming", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_pillage_inc`]) + `, "pillage_inc", "Pillage incoming", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageGo) + `, "pillage_go", "Pillage go", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_pillage_go`]) + `, "pillage_go", "Pillage go", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageTimeout) + `, "pillage_timeout", "Pillage timeout", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_pillage_timeout`]) + `, "pillage_timeout", "Pillage timeout", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageWin) + `, "pillage_win", "Pillage win", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_pillage_win`]) + `, "pillage_win", "Pillage win", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageLoss) + `, "pillage_loss", "Pillage loss", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_pillage_loss`]) + `, "pillage_loss", "Pillage loss", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTributeInc) + `, "tribute_inc", "Tribute incoming", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_tribute_inc`]) + `, "tribute_inc", "Tribute incoming", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTributeAck) + `, "tribute_ack", "Tribute acknowledged", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_tribute_ack`]) + `, "tribute_ack", "Tribute acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "auction_announce", "Auction announce", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_auction_announce`]) + `, "auction_announce", "Auction announce", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAuctionUpdReq) + `, "auction_upd_req", "Auction update request", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_auction_upd_req`]) + `, "auction_upd_req", "Auction update request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAuctionUpdAck) + `, "auction_upd_ack", "Auction update acknowledgment", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_auction_upd_ack`]) + `, "auction_upd_ack", "Auction update acknowledgment", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "time_ack", "Time Acknowledgment", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_time_ack`]) + `, "time_ack", "Time Acknowledgment", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTimeReq) + `, "time_req", "Time Request", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_time_req`]) + `, "time_req", "Time Request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGo) + `, "go", "Go", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_go`]) + `, "go", "Go", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePledge) + `, "pledge", "Pledge", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_pledge`]) + `, "pledge", "Pledge", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "go_quest_req", "Go quest Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_go_quest_req`]) + `, "go_quest_req", "Go quest Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGoFastFight) + `, "fast_fight", "Arena fast fight", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_fast_fight`]) + `, "fast_fight", "Arena fast fight", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGoArena) + `, "go_arena", "Go arena", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_go_arena`]) + `, "go_arena", "Go arena", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTop) + `, "top", "Top", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_top`]) + `, "top", "Top", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMenu) + `, "menu", "Menu", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_menu`]) + `, "menu", "Menu", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageBuyReq) + `, "buy_req", "Sell Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_buy_req`]) + `, "buy_req", "Sell Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageSellReq) + `, "sell_req", "Buy Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_sell_req`]) + `, "sell_req", "Buy Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageOrderbookReq) + `, "orderbook_req", "Orderbook Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_orderbook_req`]) + `, "orderbook_req", "Orderbook Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageOrderbookAck) + `, "orderbook_acl", "Orderbook Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_orderbook_acl`]) + `, "orderbook_acl", "Orderbook Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageWithdrawReq) + `, "withdraw_req", "Withdraw Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_withdraw_req`]) + `, "withdraw_req", "Withdraw Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageWithdrawCode) + `, "withdraw_code", "Withdraw Code", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_withdraw_code`]) + `, "withdraw_code", "Withdraw Code", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageWithdrawRcv) + `, "withdraw_rcv", "Withdraw Received", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_withdraw_rcv`]) + `, "withdraw_rcv", "Withdraw Received", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageStockReq) + `, "stock_req", "Stock Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_stock_req`]) + `, "stock_req", "Stock Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageStockAck) + `, "stock_ack", "Stock Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_stock_ack`]) + `, "stock_ack", "Stock Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMiscReq) + `, "misc_req", "Misc Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_misc_req`]) + `, "misc_req", "Misc Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMiscAck) + `, "misc_ack", "Misc Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_misc_ack`]) + `, "misc_ack", "Misc Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTUReportReq) + `, "tureport_req", "Trade Union War Report Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_tureport_req`]) + `, "tureport_req", "Trade Union War Report Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTUReportAck) + `, "tureport_ack", "Trade Union War Report Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_tureport_ack`]) + `, "tureport_ack", "Trade Union War Report Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageUnionWar) + `, "union_war", "Union war report", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_union_war`]) + `, "union_war", "Union war report", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTimeout) + `, "timeout", "Generic timeout", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_timeout`]) + `, "timeout", "Generic timeout", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGoQuestAck) + `, "go_quest_ack", "Go Quest Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_go_quest_ack`]) + `, "go_quest_ack", "Go Quest Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGRolesReq) + `, "groles_req", "Guild roles Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_groles_req`]) + `, "groles_req", "Guild roles Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGRolesAck) + `, "groles_ack", "Guild roles Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_groles_ack`]) + `, "groles_ack", "Guild roles Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockResReq) + `, "gstock_res_req", "GStock Res Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_res_req`]) + `, "gstock_res_req", "GStock Res Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockAlchReq) + `, "gstock_alch_req", "GStock Alch Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_alch_req`]) + `, "gstock_alch_req", "GStock Alch Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockMiscReq) + `, "gstock_misc_req", "GStock Misc Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_misc_req`]) + `, "gstock_misc_req", "GStock Misc Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockRecReq) + `, "gstock_rec_req", "GStock Rec Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_rec_req`]) + `, "gstock_rec_req", "GStock Rec Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockPartReq) + `, "gstock_part_req", "GStock Part Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_part_req`]) + `, "gstock_part_req", "GStock Part Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockOthReq) + `, "gstock_oth_req", "Gstock Oth Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_oth_req`]) + `, "gstock_oth_req", "Gstock Oth Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockAnyAck) + `, "gstock_any_ack", "Gstock Any Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_any_ack`]) + `, "gstock_any_ack", "Gstock Any Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockReq) + `, "gstock_req", "GStock Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_req`]) + `, "gstock_req", "GStock Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGStockAck) + `, "gstock_ack", "GStock Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_gstock_ack`]) + `, "gstock_ack", "GStock Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageBusy) + `, "busy", "Busy", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_busy`]) + `, "busy", "Busy", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageResStockReq) + `, "res_stock_req", "Resources Stock Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_res_stock_req`]) + `, "res_stock_req", "Resources Stock Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAlchStockReq) + `, "alch_stock_req", "Alchemy Stock Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_alch_stock_req`]) + `, "alch_stock_req", "Alchemy Stock Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMiscStockReq) + `, "misc_stock_req", "Misc Stock Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_misc_stock_req`]) + `, "misc_stock_req", "Misc Stock Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageEquipStockReq) + `, "equip_stock_req", "Equipment Stock Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_equip_stock_req`]) + `, "equip_stock_req", "Equipment Stock Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageCraftStockReq) + `, "craft_stock_req", "Equipment Stock Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_craft_stock_req`]) + `, "craft_stock_req", "Equipment Stock Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageStockEmpty) + `, "stock_empty", "Stock Empty", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_stock_empty`]) + `, "stock_empty", "Stock Empty", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageStockAnyAck) + `, "stock_any_ack", "Stock Any Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_stock_any_ack`]) + `, "stock_any_ack", "Stock Any Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGDepositReq) + `, "g_deposit_req", "GDeposit Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_g_deposit_req`]) + `, "g_deposit_req", "GDeposit Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGDepositAck) + `, "g_deposit_ack", "GDeposit Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_g_deposit_ack`]) + `, "g_deposit_ack", "GDeposit Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAttackReq) + `, "castle_attack_req", "Castle Attack Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_castle_attack_req`]) + `, "castle_attack_req", "Castle Attack Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAttackAck) + `, "castle_attack_ack", "Castle Attack Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_castle_attack_ack`]) + `, "castle_attack_ack", "Castle Attack Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAttackTargetReq) + `, "castle_target_req", "Castle Target Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_castle_target_req`]) + `, "castle_target_req", "Castle Target Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAttackTargetAck) + `, "castle_target_ack", "Castle Target Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_castle_target_ack`]) + `, "castle_target_ack", "Castle Target Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageDefendReq) + `, "castle_def_req", "Castle Defense Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_castle_def_req`]) + `, "castle_def_req", "Castle Defense Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageDefendAck) + `, "castle_def_ack", "Castle Defense Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_castle_def_ack`]) + `, "castle_def_ack", "Castle Defense Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageBack) + `, "back", "Back", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_back`]) + `, "back", "Back", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageCastleReq) + `, "castle_req", "Castle Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_castle_req`]) + `, "castle_req", "Castle Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageCastleAck) + `, "castle_ack", "Castle Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_castle_ack`]) + `, "castle_ack", "Castle Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageExchangeReq) + `, "exchange_req", "Exchange Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_exchange_req`]) + `, "exchange_req", "Exchange Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageExchangeAck) + `, "exchange_ack", "Exchange Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_exchange_ack`]) + `, "exchange_ack", "Exchange Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageEquipGearReq) + `, "equip_req", "Equip Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_equip_req`]) + `, "equip_req", "Equip Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageEquipGearAck) + `, "equip_ack", "Equip Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_equip_ack`]) + `, "equip_ack", "Equip Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageUnequipGearReq) + `, "unequip_req", "Unequip Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_unequip_req`]) + `, "unequip_req", "Unequip Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageUnequipGearAck) + `, "unequip_ack", "Unequip Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_unequip_ack`]) + `, "unequip_ack", "Unequip Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageNoStamina) + `, "no_stamina", "No Stamina", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_no_stamina`]) + `, "no_stamina", "No Stamina", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageOrderbookSearch) + `, "orderbook_search", "Orderbook search", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_orderbook_search`]) + `, "orderbook_search", "Orderbook search", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageQuestReq) + `, "quest_req", "Quest Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_quest_req`]) + `, "quest_req", "Quest Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageQuestAck) + `, "quest_ack", "Quest Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_quest_ack`]) + `, "quest_ack", "Quest Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageBattle) + `, "battle", "Battle", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_battle`]) + `, "battle", "Battle", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageOrderCancelReq) + `, "order_cancel_req", "Order Cancel Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_order_cancel_req`]) + `, "order_cancel_req", "Order Cancel Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageOrderCancelAck) + `, "order_cancel_ack", "Order Cancel Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_order_cancel_ack`]) + `, "order_cancel_ack", "Order Cancel Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageStaminaRestored) + `, "stamina_restored", "Stamina Restored", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_stamina_restored`]) + `, "stamina_restored", "Stamina Restored", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageHealUpFirst) + `, "heal_up", "Heal Up", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_heal_up`]) + `, "heal_up", "Heal Up", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageArenaFightAck) + `, "arena_fight_ack", "Arena Fight Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_arena_fight_ack`]) + `, "arena_fight_ack", "Arena Fight Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGoArenaAck) + `, "go_arena_ack", "Go Arena Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_go_arena`]Ack) + `, "go_arena_ack", "Go Arena Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageWithdrawNAck) + `, "withdraw_nack", "Withdraw NAck", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_withdraw_nack`]) + `, "withdraw_nack", "Withdraw NAck", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageDefeat) + `, "pillage_defeat", "Pillage Defeat", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_pillage_defeat`]) + `, "pillage_defeat", "Pillage Defeat", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageLevelUpReq) + `, "level_up_req", "Level Up Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_level_up_req`]) + `, "level_up_req", "Level Up Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageLevelUpAck) + `, "level_up_ack", "Level Up Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_level_up_ack`]) + `, "level_up_ack", "Level Up Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTopReq) + `, "top_req", "Top Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_top`]Req) + `, "top_req", "Top Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeJobPillage) + `, "job_pillage", "Pillage job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(objSubTypeJobPillage) + `, "job_pillage", "Pillage job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobTribute) + `, "job_tribute", "Tribute job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(objSubTypeJobTribute) + `, "job_tribute", "Tribute job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobGWithdraw) + `, "job_gwithdraw", "GWithdrawal job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(objSubTypeJobGWithdraw) + `, "job_gwithdraw", "GWithdrawal job", ` + strconv.Itoa(objTypeJob) + `)
@ -610,7 +610,7 @@ func initDB() {
,obj oi ,obj oi
,obj_msg_item omi ,obj_msg_item omi
WHERE om.obj_type_id = ` + strconv.Itoa(objTypeMessage) + ` WHERE om.obj_type_id = ` + strconv.Itoa(objTypeMessage) + `
AND om.obj_sub_type_id in (` + strconv.Itoa(objSubTypeMessageWithdrawRcv) + `, ` + strconv.Itoa(objSubTypeMessageGDepositAck) + `) AND om.obj_sub_type_id in (` + strconv.Itoa(cacheObjSubType[`msg_withdraw_rcv`]) + `, ` + strconv.Itoa(cacheObjSubType[`msg_g_deposit_ack`]) + `)
AND obm.obj_id = om.id AND obm.obj_id = om.id
AND omi.obj_id = om.id AND omi.obj_id = om.id
AND oi.id = omi.item_id AND oi.id = omi.item_id
@ -677,7 +677,7 @@ func insertMsgReport(objId int64, war_date int32, atk int32, def int32, exp int3
if err != nil { if err != nil {
return err return err
} }
if objSubTypeId != objSubTypeMessageUnknown { if objSubTypeId != cacheObjSubType[`msg`] {
return errors.New("Message is not of type Unknown") return errors.New("Message is not of type Unknown")
} }
/* /*
@ -711,7 +711,7 @@ func insertMsgDuelFight(m *ChatWarsMessageDuelFight) error {
if err != nil { if err != nil {
return err return err
} }
if objSubTypeId != objSubTypeMessageUnknown && objSubTypeId != objSubTypeMessageDuelFight { if objSubTypeId != cacheObjSubType[`msg`] && objSubTypeId != cacheObjSubType[`msg_duel_fight`] {
return errors.New("Message type mismatch") return errors.New("Message type mismatch")
} }
@ -735,7 +735,7 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
if err != nil { if err != nil {
return err return err
} }
if objSubTypeId != objSubTypeMessageUnknown && objSubTypeId != objSubTypeMessageAuctionAnnounce { if objSubTypeId != cacheObjSubType[`msg`] && objSubTypeId != cacheObjSubType[`msg_auction_announce`] {
return errors.New("Message type mismatch") return errors.New("Message type mismatch")
} }
@ -759,7 +759,7 @@ func insertMsgPillageInc(m *ChatWarsMessagePillageInc) error {
if err != nil { if err != nil {
return err return err
} }
if objSubTypeId != objSubTypeMessageUnknown && objSubTypeId != objSubTypeMessagePillageInc { if objSubTypeId != cacheObjSubType[`msg`] && objSubTypeId != cacheObjSubType[`msg_pillage_inc`] {
return errors.New("Message type mismatch") return errors.New("Message type mismatch")
} }