chirpnest/rules.go

102 lines
10 KiB
Go
Raw Normal View History

2019-05-19 06:06:06 +02:00
package main
import (
"strconv"
)
func resetMsgParsingRules() {
_, err := db.Exec(`TRUNCATE TABLE msg_rules;`)
failOnError(err, "resetMsgParsingRules : truncate table msg_rules")
_, err = db.Exec(`INSERT INTO msg_rules (prio, msg_type_id, descn, rule)
2019-05-19 06:19:24 +02:00
VALUES (5000, ` + strconv.Itoa(objSubTypeMessageReportAck) + `, "Player war report", "^(?P<Castle>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<User>([A-Za-z0-9 ]*)) ⚔:(?P<Attack>[0-9]+)(?P<AttackMod>\\((-|\\+)[0-9]+\\)){0,1} 🛡:(?P<Defense>[0-9]+) Lvl: (?P<Level>[0-9]+)\\nYour result on the battlefield:\\n(🔥Exp: (?P<Exp>[0-9]+)\\n){0,1}(💰Gold: (?P<Gold>\\-{0,1}[0-9]+)\\n){0,1}(📦Stock: (?P<Stock>\\-{0,1}[0-9]+)){0,1}(\\n(?P<Stamina>(🔋Stamina restored))){0,1}(\\n(?P<Crit>(⚡Critical strike))){0,1}$")
2019-05-19 06:06:06 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "Auction annouce", "^Lot #(?P<Lot>[0-9]+) : (?P<Item>.*)\\n(Quality: (?P<Quality>.*)\\n){0,1}(Condition: (?P<Cond>.*)\\n){0,1}Seller: (?P<Seller>.*)\\nCurrent price: (?P<Price>[0-9]+) pouch\\(es\\)\\nBuyer: (?P<Buyer>.*)\\nEnd At: (?P<End>.*)\\nStatus: (?P<Status>.*)(\\n)*(?s:.*)")
,(5000, ` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "Time", "^In Chat Wars world now\\n(?P<Time>.*)\\n(?P<Hour>[0-9]{2}):(?P<Minute>[0-9]{2})\\n(?P<Day>[0-9]{2}) (?P<Month>.+) (?P<Year>[0-9]{4})\\n(?s:.*)$")` +
`,(5000, ` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "Mini War", "^⛳Battle results:\\n` +
`(?P<Gardian1>🔱){0,1}.*(?P<Loot1>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result1>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold1>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock1>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian2>🔱){0,1}.*(?P<Loot2>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result2>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold2>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock2>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian3>🔱){0,1}.*(?P<Loot3>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result3>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold3>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock3>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian4>🔱){0,1}.*(?P<Loot4>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result4>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold4>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock4>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian5>🔱){0,1}.*(?P<Loot5>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result5>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold5>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock5>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian6>🔱){0,1}.*(?P<Loot6>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result6>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold6>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock6>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian7>🔱){0,1}.*(?P<Loot7>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result7>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold7>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock7>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`\\n🏆Scores:\\n` +
`.*(?P<Score1>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points1>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score2>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points2>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score3>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points3>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score4>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points4>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score5>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points5>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score6>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points6>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score7>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points7>\\+([0-9]+|NaN))\\n` +
`(?s:.*)` +
`Battle (?P<Time>[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2})$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "Pillage Inc", "^You were strolling around on your horse when you noticed (\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<Attacker>.*) of .{1}(?P<Castle>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)) Castle trying to pillage a local village. To stop him click /go$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGo) + `, "Go", "^/go$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageGo) + `,"Pillage Go", "^You lift up your sword and charge at the violator.$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageWin) + `,"Pillage Win", "^You successfully defeated (\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<Attacker>.*). As he was crawling away, you picked up some of the gold he left behind. Received (?P<Gold>[0-9]+) gold and (?P<Exp>[0-9]+) exp.$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageTimeout) + `,"Pillage Timeout", "^You\\'ve failed to protect the villagers. No more rewards for you.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageDuelFight) + `, "Duel Fight result #2", "(?P<Life1>(\\-){0,1}[0-9]+).*(?P<Castle1>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild1>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist1>.*)\\n` +
`VS\\n` +
`(?P<Life2>(\\-){0,1}[0-9]+).*(?P<Castle2>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild2>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist2>.*)\\n` +
`(?s:.*)\\n` +
`(\\[(?P<WinGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<WinDuelist>.*) from .*(?P<WinCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle stands victorious over (\\[(?P<LossGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<LossDuelist>.*) from .*(?P<LossCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle, with blood slowly dripping from his (?P<Weapon>.*).\\n` +
`You received: (?P<Exp>[0-9]+) exp.\\n` +
`(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageDuelFight) + `, "Duel Fight result #1", "(?P<Life1>(\\-){0,1}[0-9]+).*(?P<Castle1>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild1>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist1>.*)\\n` +
`VS\\n` +
`(?P<Life2>(\\-){0,1}[0-9]+).*(?P<Castle2>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild2>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist2>.*)\\n` +
`(?s:.*)\\n` +
`(\\[(?P<WinGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<WinDuelist>.*) from .*(?P<WinCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle was stronger than (\\[(?P<LossGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<LossDuelist>.*) from .*(?P<LossCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle.\\n` +
`You received: (?P<Exp>[0-9]+) exp.\\n` +
`(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageReportReq) + `, "Report request", "^/report$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGReportReq) + `, "Guild report request", "^/g_report$")
,(5000, ` + strconv.Itoa(objSubTypeMessageHeroReq) + `, "Hero request", "^/hero$")
,(5000, ` + strconv.Itoa(objSubTypeMessageMeReq) + `, "Me request", "^🏅Me$")
,(5000, ` + strconv.Itoa(objSubTypeMessageInventoryReq) + `, "Inventory request", "^/inv$")
,(5000, ` + strconv.Itoa(objSubTypeMessageTimeReq) + `, "Time request", "^/time$")
2019-05-19 08:35:26 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessagePledge) + `, "Pledge", "^/pledge$")
2019-05-19 08:51:48 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageBuyReq) + `, "Buy request", "^/wtb_(?P<Item>[0-9]+)(_(?P<Quantity>[0-9]+)){0,1}$")
,(5000, ` + strconv.Itoa(objSubTypeMessageSellReq) + `, "Sell request", "^/wts_(?P<Item>[0-9]+)(_(?P<Quantity>[0-9]+)(_(?P<Price>[0-9]+)){0,1}){0,1}$")
2019-05-19 08:35:26 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageOrderbookReq) + `, "Orderbook request", "^/t_(?P<Item>[0-9]+)$")
2019-05-20 14:29:11 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageOrderbookAck) + `, "Orderbook request", "^$")
,(5000, ` + strconv.Itoa(objSubTypeMessageWithdrawReq) + `, "Withdraw Req", "^/g_withdraw( )+(?P<Item1>[a-z0-9]+)( )+(?P<Quantity1>[0-9]+)` +
`(( )+(?P<Item2>[a-z0-9]+)( )+(?P<Quantity2>[0-9]+)){0,1}` +
`(( )+(?P<Item3>[a-z0-9]+)( )+(?P<Quantity3>[0-9]+)){0,1}` +
`(( )+(?P<Item4>[a-z0-9]+)( )+(?P<Quantity4>[0-9]+)){0,1}` +
`(( )+(?P<Item5>[a-z0-9]+)( )+(?P<Quantity5>[0-9]+)){0,1}` +
`(( )+(?P<Item6>[a-z0-9]+)( )+(?P<Quantity6>[0-9]+)){0,1}` +
`(( )+(?P<Item7>[a-z0-9]+)( )+(?P<Quantity7>[0-9]+)){0,1}` +
`(( )+(?P<Item8>[a-z0-9]+)( )+(?P<Quantity8>[0-9]+)){0,1}$")
2019-05-20 14:45:53 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageWithdrawCode) + `, "Withdraw Code #1", "^Withdrawing (?P<Item1>.*) x (?P<Quantity1>.*). Recipient shall send to bot:\\n` +
2019-05-20 14:40:16 +02:00
`/g_receive [a-z0-9]+$")
2019-05-20 14:45:53 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageWithdrawCode) + `, "Withdraw Code #2", "^Withdrawing:\\n` +
2019-05-20 14:29:11 +02:00
`(?P<Item1>.*) x (?P<Quantity1>.*)\\n` +
`((?P<Item2>.*) x (?P<Quantity2>.*)\\n){0,1}` +
`((?P<Item3>.*) x (?P<Quantity3>.*)\\n){0,1}` +
`((?P<Item4>.*) x (?P<Quantity4>.*)\\n){0,1}` +
`((?P<Item5>.*) x (?P<Quantity5>.*)\\n){0,1}` +
`((?P<Item6>.*) x (?P<Quantity6>.*)\\n){0,1}` +
`((?P<Item7>.*) x (?P<Quantity7>.*)\\n){0,1}` +
`((?P<Item8>.*) x (?P<Quantity8>.*)\\n){0,1}` +
`Recipient shall send to bot:\\n` +
`/g_receive [a-z0-9]+$")
2019-05-20 15:59:05 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageWithdrawRcv) + `, "Withdraw Received #1", "^Received (?P<Item1>.*) x (?P<Quantity1>.*)$")
2019-05-20 16:02:14 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageWithdrawRcv) + `, "Withdraw Received #2", "^Received:` +
2019-05-20 16:04:38 +02:00
`(\\n(?P<Item1>.*) x (?P<Quantity1>.*))` +
2019-05-20 16:02:14 +02:00
`(\\n(?P<Item2>.*) x (?P<Quantity2>.*)){0,1}` +
`(\\n(?P<Item3>.*) x (?P<Quantity3>.*)){0,1}` +
`(\\n(?P<Item4>.*) x (?P<Quantity4>.*)){0,1}` +
`(\\n(?P<Item5>.*) x (?P<Quantity5>.*)){0,1}` +
`(\\n(?P<Item6>.*) x (?P<Quantity6>.*)){0,1}` +
`(\\n(?P<Item7>.*) x (?P<Quantity7>.*)){0,1}` +
`(\\n(?P<Item8>.*) x (?P<Quantity8>.*)){0,1}$")
2019-05-20 14:29:11 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageDepositReq) + `, "Deposit Req", "^/g_deposit (?P<Item>[a-z0-9]+) (?P<Quantity>[0-9]+)$")
2019-05-20 14:45:53 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageDepositAck) + `, "Deposit Ack #2", "^Deposited successfully: (?P<Item>.*) \\((?P<Quantity>[0-9]+)\\)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageDepositAck) + `, "Deposit Ack #1", "^Deposited (?P<Item>.*) \\((?P<Quantity>[0-9]+)\\) successfully$")
2019-05-20 16:16:49 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageStockReq) + `, "Stock Req", "^/stock$")
,(5000, ` + strconv.Itoa(objSubTypeMessageMiscReq) + `, "Misc Req", "^/misc$")
2019-05-19 06:06:06 +02:00
;`)
failOnError(err, "resetMsgParsingRules : populate table msg_rules")
}