update items and jobs

This commit is contained in:
shoopea 2019-08-23 14:03:22 +08:00
parent 6abb634e8e
commit 7dfba868ed
5 changed files with 75 additions and 2 deletions

28
bot.go
View File

@ -21,6 +21,7 @@ func BotHandlers(b *tb.Bot) {
}) })
b.Handle("/test", botTest) b.Handle("/test", botTest)
b.Handle("/test_delay", botTestDelay)
b.Handle("/test_html", botTestHTML) b.Handle("/test_html", botTestHTML)
b.Handle("/msg_rescan", botMsgRescan) b.Handle("/msg_rescan", botMsgRescan)
b.Handle("/msg_rescan_all", botMsgRescanAll) b.Handle("/msg_rescan_all", botMsgRescanAll)
@ -163,6 +164,33 @@ func botTest(m *tb.Message) {
return return
} }
func botTestDelay(m *tb.Message) {
if !m.Private() {
return
}
if clt, ok := getLockedClient(m.Chat.ID, false); ok {
clt.Mux.Unlock()
clientSendCWMsgDelay(m.Chat.ID, "🏅Me", 5)
c := TGCommand{
Type: commandReplyMsg,
Text: "Test sent",
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
} else {
c := TGCommand{
Type: commandReplyMsg,
Text: "Client not registered",
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
}
return
}
func botGetClients(m *tb.Message) { func botGetClients(m *tb.Message) {
if !m.Private() { if !m.Private() {
return return

View File

@ -30,11 +30,16 @@ func getLockedClient(id int64, createMissing bool) (*ChirpClient, bool) {
} }
func clientSendCWMsg(userID64 int64, s string) { func clientSendCWMsg(userID64 int64, s string) {
clientSendCWMsgDelay(userID64, s, 0)
}
func clientSendCWMsgDelay(userID64 int64, s string, delay int64) {
c := TGCommand{ c := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: s, Text: s,
FromUserID64: userID64, FromUserID64: userID64,
ToChatID64: userID64ChtWrsBot, ToChatID64: userID64ChtWrsBot,
Delay: d,
} }
MQTGCmdQueue <- c MQTGCmdQueue <- c
} }
@ -45,6 +50,7 @@ func clientRefreshCWMsg(userID64 int64, chatID64 int64, msgID64 int64) {
FromUserID64: userID64, FromUserID64: userID64,
FromChatID64: chatID64, FromChatID64: chatID64,
FromMsgID64: msgID64, FromMsgID64: msgID64,
Delay: 0,
} }
MQTGCmdQueue <- c MQTGCmdQueue <- c
} }

3
def.go
View File

@ -56,6 +56,7 @@ type TGCommand struct {
Text string `json:"text"` Text string `json:"text"`
Document tb.Document `json:"document"` Document tb.Document `json:"document"`
ParseMode int64 `json:"parse_mode"` ParseMode int64 `json:"parse_mode"`
Delay int64 `json:"delay"`
} }
type ChatWarsCastle struct { type ChatWarsCastle struct {
@ -386,7 +387,7 @@ const (
objSubTypeMessageStockReq = 345 // /stock (done) objSubTypeMessageStockReq = 345 // /stock (done)
objSubTypeMessageStockAck = 346 // result from /stock (not done) objSubTypeMessageStockAck = 346 // result from /stock (not done)
objSubTypeMessageMiscReq = 347 // /misc (done) objSubTypeMessageMiscReq = 347 // /misc (done)
objSubTypeMEssageMiscAck = 348 // result from /misc (not done) objSubTypeMessageMiscAck = 348 // result from /misc (not done)
objSubTypeMessageUnionWar = 349 // from Chat Wars Reports (not done) objSubTypeMessageUnionWar = 349 // from Chat Wars Reports (not done)
objSubTypeMessageTUReportReq = 350 // /tu_report (not done) objSubTypeMessageTUReportReq = 350 // /tu_report (not done)
objSubTypeMessageTUReportAck = 351 // result from /tu_report (not done) objSubTypeMessageTUReportAck = 351 // result from /tu_report (not done)

View File

@ -41,12 +41,16 @@ func resetObjItem() {
reloadObjItem(`06`, `Charcoal`, objSubTypeItemResource, 1, true, false) reloadObjItem(`06`, `Charcoal`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`07`, `Powder`, objSubTypeItemResource, 1, true, false) reloadObjItem(`07`, `Powder`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`08`, `Iron Ore`, objSubTypeItemResource, 2, true, false) reloadObjItem(`08`, `Iron Ore`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`08`, `Iron ore`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`09`, `Cloth`, objSubTypeItemResource, 1, true, false) reloadObjItem(`09`, `Cloth`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`10`, `Silver Ore`, objSubTypeItemResource, 2, true, false) reloadObjItem(`10`, `Silver Ore`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`10`, `Silver ore`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`100`, `Pouch of Gold`, objSubTypeItemResource, 0, false, false) reloadObjItem(`100`, `Pouch of Gold`, objSubTypeItemResource, 0, false, false)
reloadObjItem(`11`, `Bauxite`, objSubTypeItemResource, 2, true, false) reloadObjItem(`11`, `Bauxite`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`12`, `Cord`, objSubTypeItemResource, 2, false, false) reloadObjItem(`12`, `Cord`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`13`, `Magic Stone`, objSubTypeItemResource, 1, true, false) reloadObjItem(`13`, `Magic Stone`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`13`, `Magic stone`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`14`, `Wooden Shaft`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`14`, `Wooden shaft`, objSubTypeItemResource, 2, false, false) reloadObjItem(`14`, `Wooden shaft`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`15`, `Sapphire`, objSubTypeItemResource, 2, true, false) reloadObjItem(`15`, `Sapphire`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`16`, `Solvent`, objSubTypeItemResource, 2, true, false) reloadObjItem(`16`, `Solvent`, objSubTypeItemResource, 2, true, false)
@ -55,19 +59,30 @@ func resetObjItem() {
reloadObjItem(`19`, `Steel`, objSubTypeItemResource, 2, true, false) reloadObjItem(`19`, `Steel`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`20`, `Leather`, objSubTypeItemResource, 1, true, false) reloadObjItem(`20`, `Leather`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`21`, `Bone Powder`, objSubTypeItemResource, 1, true, false) reloadObjItem(`21`, `Bone Powder`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`21`, `Bone powder`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`22`, `String`, objSubTypeItemResource, 1, true, false) reloadObjItem(`22`, `String`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`23`, `Coke`, objSubTypeItemResource, 1, true, false) reloadObjItem(`23`, `Coke`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`24`, `Purified Powder`, objSubTypeItemResource, 1, false, false) reloadObjItem(`24`, `Purified Powder`, objSubTypeItemResource, 1, false, false)
reloadObjItem(`24`, `Purified powder`, objSubTypeItemResource, 1, false, false)
reloadObjItem(`25`, `Silver Alloy`, objSubTypeItemResource, 3, false, false) reloadObjItem(`25`, `Silver Alloy`, objSubTypeItemResource, 3, false, false)
reloadObjItem(`25`, `Silver alloy`, objSubTypeItemResource, 3, false, false)
reloadObjItem(`27`, `Steel Mold`, objSubTypeItemResource, 2, false, false) reloadObjItem(`27`, `Steel Mold`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`27`, `Steel mold`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`28`, `Silver Mold`, objSubTypeItemResource, 2, false, false) reloadObjItem(`28`, `Silver Mold`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`28`, `Silver mold`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`29`, `Blacksmith Frame`, objSubTypeItemResource, 3, false, false) reloadObjItem(`29`, `Blacksmith Frame`, objSubTypeItemResource, 3, false, false)
reloadObjItem(`29`, `Blacksmith frame`, objSubTypeItemResource, 3, false, false)
reloadObjItem(`30`, `Artisan Frame`, objSubTypeItemResource, 3, false, false) reloadObjItem(`30`, `Artisan Frame`, objSubTypeItemResource, 3, false, false)
reloadObjItem(`30`, `Artisan frame`, objSubTypeItemResource, 3, false, false)
reloadObjItem(`31`, `Rope`, objSubTypeItemResource, 1, true, false) reloadObjItem(`31`, `Rope`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`32`, `Silver Frame`, objSubTypeItemResource, 2, false, false) reloadObjItem(`32`, `Silver Frame`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`32`, `Silver frame`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`33`, `Metal Plate`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`33`, `Metal Plate`, objSubTypeItemResource, 2, true, false) reloadObjItem(`33`, `Metal Plate`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`34`, `Metallic Fiber`, objSubTypeItemResource, 2, true, false) reloadObjItem(`34`, `Metallic Fiber`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`34`, `Metallic fiber`, objSubTypeItemResource, 2, true, false)
reloadObjItem(`35`, `Crafted Leather`, objSubTypeItemResource, 1, true, false) reloadObjItem(`35`, `Crafted Leather`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`35`, `Crafted leather`, objSubTypeItemResource, 1, true, false)
reloadObjItem(`36`, `Quality Cloth`, objSubTypeItemResource, 2, false, false) reloadObjItem(`36`, `Quality Cloth`, objSubTypeItemResource, 2, false, false)
reloadObjItem(`37`, `Blacksmith Mold`, objSubTypeItemResource, 3, false, false) reloadObjItem(`37`, `Blacksmith Mold`, objSubTypeItemResource, 3, false, false)
reloadObjItem(`38`, `Artisan Mold`, objSubTypeItemResource, 3, false, false) reloadObjItem(`38`, `Artisan Mold`, objSubTypeItemResource, 3, false, false)

25
job.go
View File

@ -713,11 +713,34 @@ func jobGDeposit(j Job) {
logOnError(err, "jobGDeposit : Unmarshal payload") logOnError(err, "jobGDeposit : Unmarshal payload")
if p.Status == 0 { /* handle remaining resources to be stored */ if p.Status == 0 { /* handle remaining resources to be stored */
var res, misc, alch, craft, equip bool = false, false, false, false, false
if len(p.ResObjID64) > 0 { if len(p.ResObjID64) > 0 {
obj, err := getObjItem(p.ResObjID64[0]) obj, err := getObjItem(p.ResObjID64[0])
logOnError(err, "jobGDeposit : getObjItem") logOnError(err, "jobGDeposit : getObjItem")
if err == nil { if err == nil {
switch obj.ItemTypeID {
case objSubTypeItemResource:
res = true
case objSubTypeItemAlch:
alch = true
case objSubTypeItemMisc:
misc = true
case objSubTypeItemRecipe:
craft = true
case objSubTypeItemPart:
craft = true
case objSubTypeItemOther:
equip = true
case objSubTypeItemUnique:
equip = true
default:
}
}
}
p2 := JobPayloadGDeposit{ p2 := JobPayloadGDeposit{
MsgID64: p.MsgID64, MsgID64: p.MsgID64,
ChatID64: p.ChatID64, ChatID64: p.ChatID64,