2019-05-06 04:54:24 +02:00
|
|
|
package main
|
|
|
|
|
2019-05-09 11:19:55 +02:00
|
|
|
import (
|
2019-05-11 05:15:42 +02:00
|
|
|
tb "gopkg.in/tucnak/telebot.v2"
|
2019-05-09 11:19:55 +02:00
|
|
|
"regexp"
|
2019-05-09 12:36:45 +02:00
|
|
|
"time"
|
2019-05-09 11:19:55 +02:00
|
|
|
)
|
|
|
|
|
2019-05-06 04:54:24 +02:00
|
|
|
type ChatWarsMessage struct {
|
2019-05-09 12:36:45 +02:00
|
|
|
UserID64 int64 `json:"user_id"`
|
|
|
|
SenderUserID64 int64 `json:"sender_user_id"`
|
|
|
|
Date time.Time `json:"date"`
|
|
|
|
ID64 int64 `json:"id"`
|
|
|
|
ChatID64 int64 `json:"chat_id"`
|
|
|
|
Text string `json:"text"`
|
2019-05-06 04:54:24 +02:00
|
|
|
}
|
2019-05-06 05:59:19 +02:00
|
|
|
|
2019-05-09 11:19:02 +02:00
|
|
|
type ChatWarsMessageAuctionAnnounce struct {
|
2019-05-11 07:41:05 +02:00
|
|
|
ObjID64 int64 `json:"obj_id"`
|
2019-05-09 12:36:45 +02:00
|
|
|
LotID int32 `json:"lot_id"`
|
|
|
|
Item string `json:"item"`
|
|
|
|
Cond string `json:"cond"`
|
|
|
|
Quality string `json:"quality"`
|
|
|
|
Seller string `json:"seller"`
|
|
|
|
Buyer string `json:"buyer"`
|
|
|
|
Price int32 `json:"price"`
|
|
|
|
Status string `json:"status"`
|
|
|
|
End time.Time `json:"end"`
|
2019-05-09 11:19:02 +02:00
|
|
|
}
|
|
|
|
|
2019-05-11 12:45:05 +02:00
|
|
|
type ChatWarsMessageMiniWar struct {
|
|
|
|
Report map[string]ChatWarsMessageMiniWarCastle `json:"castle"`
|
|
|
|
Time time.Time `json:"time"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ChatWarsMessageMiniWarCastle struct {
|
2019-05-11 13:22:50 +02:00
|
|
|
Gardian string `json:"gardian"`
|
|
|
|
Result string `json:"result"`
|
|
|
|
Gold int32 `json:"gold"`
|
|
|
|
Stock int32 `json:"stock"`
|
|
|
|
Points int32 `json:"points"`
|
2019-05-11 12:45:05 +02:00
|
|
|
}
|
|
|
|
|
2019-05-07 13:15:25 +02:00
|
|
|
type MessageParsingRule struct {
|
|
|
|
ID int32
|
|
|
|
Priority int32
|
|
|
|
Description string
|
|
|
|
Rule string
|
|
|
|
MsgTypeID int32
|
2019-05-08 12:33:52 +02:00
|
|
|
re *regexp.Regexp
|
2019-05-07 13:15:25 +02:00
|
|
|
}
|
|
|
|
|
2019-05-11 05:15:42 +02:00
|
|
|
type BotMsg struct {
|
|
|
|
To tb.Recipient
|
|
|
|
Text string
|
|
|
|
}
|
|
|
|
|
2019-05-10 11:23:47 +02:00
|
|
|
type Job struct {
|
|
|
|
ID64 int64
|
|
|
|
JobTypeID int32
|
2019-05-11 06:54:12 +02:00
|
|
|
Status int32
|
2019-05-10 11:23:47 +02:00
|
|
|
Payload []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
type JobPayloadPillage struct {
|
|
|
|
UserID64 int64 `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type JobPayloadTribute struct {
|
|
|
|
UserID64 int64 `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type JobPayloadStatus struct {
|
|
|
|
UserID64 int64 `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type JobPayloadWithdrawal struct {
|
|
|
|
UserID64 int64 `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type JobPayloadGStock struct {
|
|
|
|
UserID64 int64 `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type JobPayloadRescanMsg struct {
|
2019-05-11 05:15:42 +02:00
|
|
|
Query string `json:"query"`
|
2019-05-10 13:33:29 +02:00
|
|
|
}
|
|
|
|
|
2019-05-11 06:54:12 +02:00
|
|
|
type JobPayloadSetDone struct {
|
|
|
|
JobID64 int64 `json:"job_id"`
|
|
|
|
}
|
|
|
|
|
2019-05-06 05:59:19 +02:00
|
|
|
const (
|
2019-05-07 05:12:03 +02:00
|
|
|
objTypeUser = 1
|
|
|
|
objTypeGuild = 2
|
|
|
|
objTypeMessage = 3
|
|
|
|
objTypeWar = 4
|
|
|
|
objTypeWarReport = 5
|
2019-05-07 13:15:25 +02:00
|
|
|
objTypeJob = 6
|
2019-05-09 09:17:59 +02:00
|
|
|
objTypeItem = 7
|
2019-05-06 05:59:19 +02:00
|
|
|
|
2019-05-08 16:34:47 +02:00
|
|
|
objSubTypeMessageUnknown = 301
|
|
|
|
objSubTypeMessageWar = 302
|
|
|
|
objSubTypeMessageMiniWar = 303
|
|
|
|
objSubTypeMessageGuildWar = 304
|
|
|
|
objSubTypeMessageReport = 305
|
|
|
|
objSubTypeMessageGReport = 306
|
|
|
|
objSubTypeMessageQuest = 307
|
|
|
|
objSubTypeMessageFight = 308
|
|
|
|
objSubTypeMessageHero = 309
|
|
|
|
objSubTypeMessageMe = 310
|
|
|
|
objSubTypeMessageInventory = 311
|
|
|
|
objSubTypeMessagePillageInc = 312
|
|
|
|
objSubTypeMessageTributeInc = 313
|
|
|
|
objSubTypeMessagePillageAck = 314
|
|
|
|
objSubTypeMessageTributeAck = 315
|
|
|
|
objSubTypeMessageAuctionAnnounce = 316
|
2019-05-10 04:26:37 +02:00
|
|
|
objSubTypeMessageAuctionUpdReq = 317
|
2019-05-11 08:24:38 +02:00
|
|
|
objSubTypeMessageAuctionUpdAck = 318
|
|
|
|
objSubTypeMessageTimeAck = 319
|
|
|
|
objSubTypeMessageTimeReq = 320
|
2019-05-08 16:34:47 +02:00
|
|
|
objSubTypeJobPillage = 601
|
|
|
|
objSubTypeJobTribute = 602
|
|
|
|
objSubTypeJobStatus = 603
|
|
|
|
objSubTypeJobWithdrawal = 604
|
|
|
|
objSubTypeJobGStock = 605
|
2019-05-10 11:23:47 +02:00
|
|
|
objSubTypeJobRescanMsg = 606
|
2019-05-11 06:54:12 +02:00
|
|
|
objSubTypeJobSetJobDone = 607
|
2019-05-09 09:17:59 +02:00
|
|
|
objSubTypeItemResource = 701
|
|
|
|
objSubTypeItemAlch = 702
|
|
|
|
objSubTypeItemMisc = 703
|
|
|
|
objSubTypeItemRecipe = 704
|
|
|
|
objSubTypeItemPart = 705
|
|
|
|
objSubTypeItemOther = 706
|
2019-05-06 09:25:57 +02:00
|
|
|
|
2019-05-10 11:23:47 +02:00
|
|
|
objJobStatusNew = 0
|
|
|
|
objJonStatusPending = 10
|
|
|
|
objJobStatusDone = 20
|
|
|
|
|
2019-05-11 06:54:12 +02:00
|
|
|
objJobPriority = 1
|
|
|
|
objJobPriorityRescanMsg = 2
|
|
|
|
objJobPriorityRescanChildMsg = 3
|
|
|
|
objJobPriorityRescanAllMsg = 4
|
|
|
|
|
2019-05-11 10:04:27 +02:00
|
|
|
MQGetMsgWorkers = 12
|
2019-05-06 09:25:57 +02:00
|
|
|
SQLCWMsgWorkers = 6
|
|
|
|
SQLIdentifyMsgWorkers = 6
|
2019-05-07 13:15:25 +02:00
|
|
|
SQLJobWorkers = 3
|
2019-05-10 11:28:05 +02:00
|
|
|
SQLJobSliceSize = 25
|
2019-05-06 05:59:19 +02:00
|
|
|
)
|
2019-05-08 17:18:17 +02:00
|
|
|
|
2019-05-09 04:27:21 +02:00
|
|
|
var (
|
|
|
|
chatWarsMonth = map[string]int{
|
|
|
|
"Wintar": 1,
|
|
|
|
"Hornung": 2,
|
|
|
|
"Lenzin": 3,
|
|
|
|
"Ōstar": 4,
|
|
|
|
"Winni": 5,
|
|
|
|
"Brāh": 6,
|
|
|
|
"Hewi": 7,
|
|
|
|
"Aran": 8,
|
|
|
|
"Witu": 9,
|
|
|
|
"Wīndume": 10,
|
|
|
|
"Herbist": 11,
|
|
|
|
"Hailag": 12}
|
2019-05-09 04:28:06 +02:00
|
|
|
|
|
|
|
chatWarsDaysSpecial = map[int]map[int]int{
|
|
|
|
2: {1060: 29},
|
|
|
|
4: {1060: 29}}
|
|
|
|
|
2019-05-09 04:27:21 +02:00
|
|
|
chatWarsDays = map[int]int{
|
|
|
|
1: 31,
|
|
|
|
2: 28,
|
|
|
|
3: 31,
|
|
|
|
4: 30,
|
|
|
|
5: 31,
|
|
|
|
6: 30,
|
|
|
|
7: 31,
|
|
|
|
8: 31,
|
|
|
|
9: 30,
|
|
|
|
10: 31,
|
|
|
|
11: 30,
|
|
|
|
12: 31}
|
|
|
|
)
|