craft stock
This commit is contained in:
parent
13a0e3a9de
commit
49903fc889
3
bot.go
3
bot.go
@ -107,7 +107,8 @@ func botHelp(m *tb.Message) {
|
|||||||
/backup_export - export message database
|
/backup_export - export message database
|
||||||
/backup_import <URL> - import message database from URL
|
/backup_import <URL> - import message database from URL
|
||||||
/get_item_id <string> - identify item_id from string
|
/get_item_id <string> - identify item_id from string
|
||||||
/clients - list all connected clients`,
|
/clients - list all connected clients
|
||||||
|
/g_deposit_all - deposit all res to vault`,
|
||||||
FromMsgID64: int64(m.ID),
|
FromMsgID64: int64(m.ID),
|
||||||
FromChatID64: m.Chat.ID,
|
FromChatID64: m.Chat.ID,
|
||||||
}
|
}
|
||||||
|
5
def.go
5
def.go
@ -132,6 +132,11 @@ type ChatWarsMessageStockAck struct {
|
|||||||
Stock []ChatWarsItems `json:"stock"`
|
Stock []ChatWarsItems `json:"stock"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChatWarsMessageStockAnyAck struct {
|
||||||
|
Msg *ChatWarsMessage `json:"msg"`
|
||||||
|
Stock []ChatWarsItems `json:"stock"`
|
||||||
|
}
|
||||||
|
|
||||||
type ChatWarsMessageOrderbookAck struct {
|
type ChatWarsMessageOrderbookAck struct {
|
||||||
Msg *ChatWarsMessage `json:"msg"`
|
Msg *ChatWarsMessage `json:"msg"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
22
msg.go
22
msg.go
@ -23,6 +23,28 @@ func getMsgParsingRule(m *ChatWarsMessage) (*MessageParsingRule, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseSubTypeMessageStockAnyAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageStockAnyAck, error) {
|
||||||
|
cwm := ChatWarsMessageStockAnyAck{}
|
||||||
|
items := []ChatWarsItems{}
|
||||||
|
|
||||||
|
re := regexp.MustCompile(`([a-zA-Z ]+) \(([0-9]+)\)\n{0,1}`)
|
||||||
|
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) {
|
||||||
|
i := getObjItemID(``, l[1])
|
||||||
|
q, _ := strconv.ParseInt(l[2], 10, 64)
|
||||||
|
if i != 0 {
|
||||||
|
item := ChatWarsItems{
|
||||||
|
ItemID64: i,
|
||||||
|
Quantity: q,
|
||||||
|
}
|
||||||
|
items = append(items, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cwm.Stock = items
|
||||||
|
cwm.Msg = m
|
||||||
|
return &cwm, nil
|
||||||
|
}
|
||||||
|
|
||||||
func parseSubTypeMessageGDepositReq(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageGDepositReq, error) {
|
func parseSubTypeMessageGDepositReq(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageGDepositReq, error) {
|
||||||
cwm := ChatWarsMessageGDepositReq{}
|
cwm := ChatWarsMessageGDepositReq{}
|
||||||
|
|
||||||
|
2
rules.go
2
rules.go
@ -200,7 +200,7 @@ func resetMsgParsingRules() {
|
|||||||
,(5000, ` + strconv.Itoa(objSubTypeMessageEquipStockReq) + `, "Equipment Stock Req", "^🏷Equipment$")
|
,(5000, ` + strconv.Itoa(objSubTypeMessageEquipStockReq) + `, "Equipment Stock Req", "^🏷Equipment$")
|
||||||
,(5000, ` + strconv.Itoa(objSubTypeMessageCraftStockReq) + `, "Crafting Stock Req", "^⚒Crafting$")
|
,(5000, ` + strconv.Itoa(objSubTypeMessageCraftStockReq) + `, "Crafting Stock Req", "^⚒Crafting$")
|
||||||
,(5000, ` + strconv.Itoa(objSubTypeMessageStockEmpty) + `, "Stock Empty", "^\\[empty\\]$")
|
,(5000, ` + strconv.Itoa(objSubTypeMessageStockEmpty) + `, "Stock Empty", "^\\[empty\\]$")
|
||||||
,(5000, ` + strconv.Itoa(objSubTypeMessageStockAnyAck) + `, "Any Stock Ack", "^$")
|
,(5000, ` + strconv.Itoa(objSubTypeMessageStockAnyAck) + `, "Any Stock Ack", "^(?P<Items>(([a-zA-Z ]+ \\([0-9]+\\)\\n{0,1})+)$")
|
||||||
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositReq) + `, "GDeposit Req", "^/g_deposit (?P<Item>[a-z0-9]+) (?P<Quantity>[0-9]+)$")
|
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositReq) + `, "GDeposit Req", "^/g_deposit (?P<Item>[a-z0-9]+) (?P<Quantity>[0-9]+)$")
|
||||||
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositAck) + `, "GDeposit Ack #2", "^Deposited successfully: (?P<Item>.*) \\((?P<Quantity>[0-9]+)\\)$")
|
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositAck) + `, "GDeposit Ack #2", "^Deposited successfully: (?P<Item>.*) \\((?P<Quantity>[0-9]+)\\)$")
|
||||||
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositAck) + `, "GDeposit Ack #1", "^Deposited (?P<Item>.*) \\((?P<Quantity>[0-9]+)\\) successfully$")
|
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositAck) + `, "GDeposit Ack #1", "^Deposited (?P<Item>.*) \\((?P<Quantity>[0-9]+)\\) successfully$")
|
||||||
|
@ -468,6 +468,9 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
case objSubTypeMessageGDepositAck:
|
case objSubTypeMessageGDepositAck:
|
||||||
_, err := parseSubTypeMessageGDepositAck(m, rule.re)
|
_, err := parseSubTypeMessageGDepositAck(m, rule.re)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageGDepositAck.")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageGDepositAck.")
|
||||||
|
case objSubTypeMessageStockAnyAck:
|
||||||
|
_, err := parseSubTypeMessageStockAnyAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageStockAnyAck.")
|
||||||
default:
|
default:
|
||||||
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID, objId, m.Text)
|
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID, objId, m.Text)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user