331 lines
16 KiB
Go
331 lines
16 KiB
Go
package main
|
|
|
|
import (
|
|
"archive/zip"
|
|
"bytes"
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
"regexp"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
func parseSubTypeMessageReportAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageReportAck, error) {
|
|
cwm := ChatWarsMessageReportAck{}
|
|
/*
|
|
log.Printf("parseSubTypeMessageReport : War report identified\n")
|
|
log.Printf("parseSubTypeMessageReport : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))
|
|
log.Printf("parseSubTypeMessageReport : Guild : %s\n", r.ReplaceAllString(m.Text, "${Guild}"))
|
|
log.Printf("parseSubTypeMessageReport : User : %s\n", r.ReplaceAllString(m.Text, "${User}"))
|
|
log.Printf("parseSubTypeMessageReport : Attack : %s\n", r.ReplaceAllString(m.Text, "${Attack}"))
|
|
log.Printf("parseSubTypeMessageReport : AttackMod : %s\n", r.ReplaceAllString(m.Text, "${AttackMod}"))
|
|
log.Printf("parseSubTypeMessageReport : Defense : %s\n", r.ReplaceAllString(m.Text, "${Defense}"))
|
|
log.Printf("parseSubTypeMessageReport : Level : %s\n", r.ReplaceAllString(m.Text, "${Level}"))
|
|
log.Printf("parseSubTypeMessageReport : Exp : %s\n", r.ReplaceAllString(m.Text, "${Exp}"))
|
|
log.Printf("parseSubTypeMessageReport : Gold : %s\n", r.ReplaceAllString(m.Text, "${Gold}"))
|
|
log.Printf("parseSubTypeMessageReport : Stock : %s\n", r.ReplaceAllString(m.Text, "${Stock}"))
|
|
log.Printf("parseSubTypeMessageReport : Stamina : %s\n", r.ReplaceAllString(m.Text, "${Stamina}"))
|
|
log.Printf("parseSubTypeMessageReport : Crit : %s\n", r.ReplaceAllString(m.Text, "${Crit}"))
|
|
*/
|
|
return &cwm, nil
|
|
}
|
|
|
|
func parseSubTypeMessageAuctionAnnounce(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageAuctionAnnounce, error) {
|
|
cwm := ChatWarsMessageAuctionAnnounce{}
|
|
|
|
l, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${Lot}"), 10, 32)
|
|
cwm.LotID = int32(l)
|
|
cwm.ItemID64 = getObjItemID(``, r.ReplaceAllString(m.Text, "${Item}"))
|
|
cwm.Cond = r.ReplaceAllString(m.Text, "${Cond}")
|
|
cwm.Quality = r.ReplaceAllString(m.Text, "${Quality}")
|
|
cwm.SellerUserID64 = getObjUserID(r.ReplaceAllString(m.Text, "${SellerUser}"))
|
|
cwm.SellerGuildID64 = getObjUserID(r.ReplaceAllString(m.Text, "${SellerGuild}"))
|
|
cwm.SellerCastleID64 = getObjUserID(r.ReplaceAllString(m.Text, "${SellerCastle}"))
|
|
cwm.BuyerUserID64 = getObjUserID(r.ReplaceAllString(m.Text, "${BuyerUser}"))
|
|
cwm.BuyerGuildID64 = getObjUserID(r.ReplaceAllString(m.Text, "${BuyerGuild}"))
|
|
cwm.BuyerCastleID64 = getObjUserID(r.ReplaceAllString(m.Text, "${BuyerCastle}"))
|
|
p, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${Price}"), 10, 32)
|
|
cwm.Price = int32(p)
|
|
cwm.Status = r.ReplaceAllString(m.Text, "${Status}")
|
|
cwm.End, _ = fromChatWarsDate(r.ReplaceAllString(m.Text, "${End}"))
|
|
|
|
return &cwm, nil
|
|
}
|
|
|
|
func parseSubTypeMessageGStockAnyAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageStock, error) {
|
|
cwm := ChatWarsMessageStock{}
|
|
items := []ChatWarsItems{}
|
|
re := regexp.MustCompile(`\n([0-9a-z]+) (.*) x ([0-9]+)`)
|
|
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Stock}"), -1) {
|
|
i := getObjItemID(l[1], l[2])
|
|
q, _ := strconv.ParseInt(l[3], 10, 64)
|
|
if i != 0 {
|
|
item := ChatWarsItems{
|
|
ItemID64: i,
|
|
Quantity: q,
|
|
}
|
|
items = append(items, item)
|
|
}
|
|
}
|
|
cwm.ItemList = items
|
|
return &cwm, nil
|
|
}
|
|
|
|
func parseSubTypeMessageMeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageMeAck, error) {
|
|
var i int64
|
|
|
|
cwm := ChatWarsMessageMeAck{
|
|
UserID64: getObjUserID(r.ReplaceAllString(m.Text, "${Player}")),
|
|
GuildID64: getObjGuildID(r.ReplaceAllString(m.Text, "${Guild}")),
|
|
State: r.ReplaceAllString(m.Text, "${State}"),
|
|
}
|
|
i, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${ExpNow}"), 10, 64)
|
|
cwm.ExpNow = i
|
|
i, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${ExpLvl}"), 10, 64)
|
|
cwm.ExpLvl = i
|
|
i, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Level}"), 10, 64)
|
|
cwm.Level = i
|
|
|
|
/*
|
|
log.Printf("parseSubTypeMessageReport : Me report identified\n")
|
|
log.Printf("parseSubTypeMessageReport : Class : %s\n", r.ReplaceAllString(m.Text, "${Class}"))
|
|
log.Printf("parseSubTypeMessageReport : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))
|
|
log.Printf("parseSubTypeMessageReport : Level : %s\n", r.ReplaceAllString(m.Text, "${Level}"))
|
|
log.Printf("parseSubTypeMessageReport : Atk : %s\n", r.ReplaceAllString(m.Text, "${Atk}"))
|
|
log.Printf("parseSubTypeMessageReport : Def : %s\n", r.ReplaceAllString(m.Text, "${Def}"))
|
|
log.Printf("parseSubTypeMessageReport : ExpNow : %s\n", r.ReplaceAllString(m.Text, "${ExpNow}"))
|
|
log.Printf("parseSubTypeMessageReport : ExpLvl : %s\n", r.ReplaceAllString(m.Text, "${ExpLvl}"))
|
|
log.Printf("parseSubTypeMessageReport : StaminaNow : %s\n", r.ReplaceAllString(m.Text, "${StaminaNow}"))
|
|
log.Printf("parseSubTypeMessageReport : StaminaMax : %s\n", r.ReplaceAllString(m.Text, "${StaminaMax}"))
|
|
log.Printf("parseSubTypeMessageReport : Gold : %s\n", r.ReplaceAllString(m.Text, "${Gold}"))
|
|
log.Printf("parseSubTypeMessageReport : Pogs : %s\n", r.ReplaceAllString(m.Text, "${Pogs}"))
|
|
log.Printf("parseSubTypeMessageReport : Gems : %s\n", r.ReplaceAllString(m.Text, "${Gems}"))
|
|
log.Printf("parseSubTypeMessageReport : AtkGear : %s\n", r.ReplaceAllString(m.Text, "${AtkGear}"))
|
|
log.Printf("parseSubTypeMessageReport : DefGear : %s\n", r.ReplaceAllString(m.Text, "${DefGear}"))
|
|
log.Printf("parseSubTypeMessageReport : BagUsed : %s\n", r.ReplaceAllString(m.Text, "${BagUsed}"))
|
|
log.Printf("parseSubTypeMessageReport : BagDispo : %s\n", r.ReplaceAllString(m.Text, "${BagDispo}"))
|
|
*/
|
|
return &cwm, nil
|
|
}
|
|
|
|
func parseSubTypeMessageGRolesAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageGRolesAck, error) {
|
|
cwm := ChatWarsMessageGRolesAck{
|
|
Msg: m,
|
|
}
|
|
/*
|
|
BartenderID64: getObjUserID(r.ReplaceAllString(m.Text, "${Bartender}")),
|
|
CommanderID64: getObjUserID(r.ReplaceAllString(m.Text, "${Commander}")),
|
|
SquireID64: getObjUserID(r.ReplaceAllString(m.Text, "${Squire}")),
|
|
TreasurerID64: getObjUserID(r.ReplaceAllString(m.Text, "${Treasurer}")),
|
|
*/
|
|
if strings.Compare(`[unassigned]`, r.ReplaceAllString(m.Text, "${Bartender}")) != 0 {
|
|
s := r.ReplaceAllString(m.Text, "${Bartender}")
|
|
_, i := utf8.DecodeRuneInString(s)
|
|
_, j := utf8.DecodeRuneInString(s[i:])
|
|
cwm.BartenderID64 = getObjUserID(s[i+j:])
|
|
} else {
|
|
cwm.BartenderID64 = 0
|
|
}
|
|
if strings.Compare(`[unassigned]`, r.ReplaceAllString(m.Text, "${Commander}")) != 0 {
|
|
s := r.ReplaceAllString(m.Text, "${Commander}")
|
|
_, i := utf8.DecodeRuneInString(s)
|
|
_, j := utf8.DecodeRuneInString(s[i:])
|
|
cwm.CommanderID64 = getObjUserID(s[i+j:])
|
|
} else {
|
|
cwm.CommanderID64 = 0
|
|
}
|
|
if strings.Compare(`[unassigned]`, r.ReplaceAllString(m.Text, "${Squire}")) != 0 {
|
|
s := r.ReplaceAllString(m.Text, "${Squire}")
|
|
_, i := utf8.DecodeRuneInString(s)
|
|
_, j := utf8.DecodeRuneInString(s[i:])
|
|
cwm.SquireID64 = getObjUserID(s[i+j:])
|
|
} else {
|
|
cwm.SquireID64 = 0
|
|
}
|
|
if strings.Compare(`[unassigned]`, r.ReplaceAllString(m.Text, "${Treasurer}")) != 0 {
|
|
s := r.ReplaceAllString(m.Text, "${Treasurer}")
|
|
_, i := utf8.DecodeRuneInString(s)
|
|
_, j := utf8.DecodeRuneInString(s[i:])
|
|
cwm.TreasurerID64 = getObjUserID(s[i+j:])
|
|
} else {
|
|
cwm.TreasurerID64 = 0
|
|
}
|
|
/*
|
|
log.Printf("parseSubTypeMessageGRolesAck : Guild roles Ack identified\n")
|
|
log.Printf("parseSubTypeMessageGRolesAck : Bartender : %s\n", r.ReplaceAllString(m.Text, "${Bartender}"))
|
|
log.Printf("parseSubTypeMessageGRolesAck : Commander : %s\n", r.ReplaceAllString(m.Text, "${Commander}"))
|
|
log.Printf("parseSubTypeMessageGRolesAck : Squire : %s\n", r.ReplaceAllString(m.Text, "${Squire}"))
|
|
log.Printf("parseSubTypeMessageGRolesAck : Treasurer : %s\n", r.ReplaceAllString(m.Text, "${Treasurer}"))
|
|
log.Printf("cwm.BartenderID64 : %d\n", cwm.BartenderID64)
|
|
log.Printf("cwm.CommanderID64 : %d\n", cwm.CommanderID64)
|
|
log.Printf("cwm.SquireID64 : %d\n", cwm.SquireID64)
|
|
log.Printf("cwm.TreasurerID64 : %d\n", cwm.TreasurerID64)
|
|
*/
|
|
return &cwm, nil
|
|
}
|
|
|
|
func parseSubTypeMessageGoQuestAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageGoQuestAck, error) {
|
|
cwm := ChatWarsMessageGoQuestAck{}
|
|
log.Printf("parseSubTypeMessageGoQuestAck : Go Quest Ack report identified\n")
|
|
log.Printf("parseSubTypeMessageGoQuestAck : Place : %s\n", r.ReplaceAllString(m.Text, "${Place}"))
|
|
log.Printf("parseSubTypeMessageGoQuestAck : Time : %s\n", r.ReplaceAllString(m.Text, "${Time}"))
|
|
return &cwm, nil
|
|
}
|
|
|
|
func parseSubTypeMessageUnionWar(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageUnionWar, error) {
|
|
//re := regexp.MustCompile('^(🏠Trade union news:\\n)(?P<Union>(?s:[^(🎪State of exclusive rights)]*))(🎪State of exclusive rights:)(?P<Fair>(?s:.*))$')
|
|
|
|
/*
|
|
"^(🏠Trade union news:\\n){0,1}` +
|
|
`(((?P<Union>[A-Z][a-z]+ [A-Z][a-z]+) was (?P<Status>(easily defended|defended successfully|breached.|easily breached.|closely breached.))(Attackers have pillage union for (?<Loot>[0-9]+) stock):\\n` +
|
|
`(🎖Attack leaders: (?P<AtkCastle1>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser1>[^,]+)(,(?P<AtkCastle2>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser2>[^,]+)){0,1}(,(?P<AtkCastle3>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser3>[^,]+)){0,1}(,(?P<AtkCastle4>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser4>[^,]+)){0,1}){0,1}(\\n){0,1}` +
|
|
`(🎖Defense leaders: (?P<DefCastle1>[🐉🦅🐺🦈🦌🥔🌑])(?P<DefUser1>[^,]+)(,(?P<DefCastle2>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser2>[^,]+)){0,1}(,(?P<DefCastle3>[🐉🦅🐺🦈🦌🥔🌑])(?P<DefUser3>[^,]+)){0,1}(,(?P<DefCastle4>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser4>[^,]+)){0,1}){0,1}(\\n){0,1})(\\n)*)*` +
|
|
`(🎪State of exclusive rights:\\n){0,1}` +
|
|
`(((?P<Fair>[A-Z][a-z]+ [A-Z][a-z]+) (?P<Status>(was protected|belongs to)( (?P<Attacker>[A-Z][a-z]+ [A-Z][a-z]+):)\\n` +
|
|
`(🎖Attack leaders: (?P<AtkCastle1>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser1>[^,]+)(,(?P<AtkCastle2>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser2>[^,]+)){0,1}(,(?P<AtkCastle3>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser3>[^,]+)){0,1}(,(?P<AtkCastle4>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser4>[^,]+)){0,1}){0,1}(\\n){0,1}` +
|
|
`(🎖Defense leaders: (?P<DefCastle1>[🐉🦅🐺🦈🦌🥔🌑])(?P<DefUser1>[^,]+)(,(?P<DefCastle2>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser2>[^,]+)){0,1}(,(?P<DefCastle3>[🐉🦅🐺🦈🦌🥔🌑])(?P<DefUser3>[^,]+)){0,1}(,(?P<DefCastle4>[🐉🦅🐺🦈🦌🥔🌑])(?P<AtkUser4>[^,]+)){0,1}){0,1}(\\n){0,1})(\\n)*)*` +
|
|
`$)"
|
|
*/
|
|
cwm := ChatWarsMessageUnionWar{}
|
|
/*
|
|
log.Printf("parseSubTypeMessageReport : War report identified\n")
|
|
log.Printf("parseSubTypeMessageReport : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))
|
|
log.Printf("parseSubTypeMessageReport : Guild : %s\n", r.ReplaceAllString(m.Text, "${Guild}"))
|
|
log.Printf("parseSubTypeMessageReport : User : %s\n", r.ReplaceAllString(m.Text, "${User}"))
|
|
log.Printf("parseSubTypeMessageReport : Attack : %s\n", r.ReplaceAllString(m.Text, "${Attack}"))
|
|
log.Printf("parseSubTypeMessageReport : AttackMod : %s\n", r.ReplaceAllString(m.Text, "${AttackMod}"))
|
|
log.Printf("parseSubTypeMessageReport : Defense : %s\n", r.ReplaceAllString(m.Text, "${Defense}"))
|
|
log.Printf("parseSubTypeMessageReport : Level : %s\n", r.ReplaceAllString(m.Text, "${Level}"))
|
|
log.Printf("parseSubTypeMessageReport : Exp : %s\n", r.ReplaceAllString(m.Text, "${Exp}"))
|
|
log.Printf("parseSubTypeMessageReport : Gold : %s\n", r.ReplaceAllString(m.Text, "${Gold}"))
|
|
log.Printf("parseSubTypeMessageReport : Stock : %s\n", r.ReplaceAllString(m.Text, "${Stock}"))
|
|
log.Printf("parseSubTypeMessageReport : Stamina : %s\n", r.ReplaceAllString(m.Text, "${Stamina}"))
|
|
log.Printf("parseSubTypeMessageReport : Crit : %s\n", r.ReplaceAllString(m.Text, "${Crit}"))
|
|
*/
|
|
return &cwm, nil
|
|
}
|
|
|
|
func parseSubTypeMessageDuelFight(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageDuelFight, error) {
|
|
cwm := ChatWarsMessageDuelFight{}
|
|
if r.ReplaceAllString(m.Text, "${Duelist1}") == r.ReplaceAllString(m.Text, "${WinDuelist}") {
|
|
cwm.WinCastle = r.ReplaceAllString(m.Text, "${Castle1}")
|
|
cwm.WinGuild = r.ReplaceAllString(m.Text, "${Guild1}")
|
|
cwm.WinUser = r.ReplaceAllString(m.Text, "${Duelist1}")
|
|
cwm.WinLife, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Life1}"), 10, 64)
|
|
cwm.LossCastle = r.ReplaceAllString(m.Text, "${Castle2}")
|
|
cwm.LossGuild = r.ReplaceAllString(m.Text, "${Guild2}")
|
|
cwm.LossUser = r.ReplaceAllString(m.Text, "${Duelist2}")
|
|
cwm.LossLife, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Life2}"), 10, 64)
|
|
} else {
|
|
cwm.LossCastle = r.ReplaceAllString(m.Text, "${Castle1}")
|
|
cwm.LossGuild = r.ReplaceAllString(m.Text, "${Guild1}")
|
|
cwm.LossUser = r.ReplaceAllString(m.Text, "${Duelist1}")
|
|
cwm.LossLife, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Life1}"), 10, 64)
|
|
cwm.WinCastle = r.ReplaceAllString(m.Text, "${Castle2}")
|
|
cwm.WinGuild = r.ReplaceAllString(m.Text, "${Guild2}")
|
|
cwm.WinUser = r.ReplaceAllString(m.Text, "${Duelist2}")
|
|
cwm.WinLife, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Life2}"), 10, 64)
|
|
}
|
|
cwm.Weapon = r.ReplaceAllString(m.Text, "${Weapon}")
|
|
|
|
return &cwm, nil
|
|
}
|
|
|
|
func parseSubTypeMessageMiniWar(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageMiniWar, error) {
|
|
t, err := time.Parse("02/01/06 15:04", r.ReplaceAllString(m.Text, "${Time}"))
|
|
logOnError(err, "parseSubTypeMessageMiniWar : parsing time : "+r.ReplaceAllString(m.Text, "${Time}"))
|
|
cwm := ChatWarsMessageMiniWar{
|
|
Time: t,
|
|
Report: make(map[string]*ChatWarsMessageMiniWarCastle),
|
|
}
|
|
for i := 1; i <= 7; i++ {
|
|
loot := fmt.Sprintf("${Loot%d}", i)
|
|
gardian := fmt.Sprintf("${Gardian%d}", i)
|
|
result := fmt.Sprintf("${Result%d}", i)
|
|
gold := fmt.Sprintf("${Gold%d}", i)
|
|
stock := fmt.Sprintf("${Stock%d}", i)
|
|
rep := ChatWarsMessageMiniWarCastle{
|
|
Gardian: r.ReplaceAllString(m.Text, gardian),
|
|
Result: r.ReplaceAllString(m.Text, result),
|
|
}
|
|
rep.Gold, err = strconv.ParseInt(r.ReplaceAllString(m.Text, gold), 10, 64)
|
|
rep.Stock, err = strconv.ParseInt(r.ReplaceAllString(m.Text, stock), 10, 64)
|
|
cwm.Report[r.ReplaceAllString(m.Text, loot)] = &rep
|
|
}
|
|
for i := 1; i <= 7; i++ {
|
|
score := fmt.Sprintf("${Score%d}", i)
|
|
points := fmt.Sprintf("${Points%d}", i)
|
|
cwm.Report[r.ReplaceAllString(m.Text, score)].Points, err = strconv.ParseInt(r.ReplaceAllString(m.Text, points), 10, 64)
|
|
}
|
|
|
|
return &cwm, err
|
|
}
|
|
|
|
func parseSubTypeMessagePillageInc(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessagePillageInc, error) {
|
|
cwm := ChatWarsMessagePillageInc{}
|
|
cwm.Attacker = r.ReplaceAllString(m.Text, "${Attacker}")
|
|
cwm.Castle = r.ReplaceAllString(m.Text, "${Castle}")
|
|
cwm.Guild = r.ReplaceAllString(m.Text, "${Guild}")
|
|
|
|
return &cwm, nil
|
|
}
|
|
|
|
func zipMessages() ([]byte, error) {
|
|
bkp := DataBackup{}
|
|
s := new([]ChatWarsMessage)
|
|
msgs := *s
|
|
ids := getSQLListID64(`SELECT om.obj_id id FROM obj_msg om;`)
|
|
log.Printf("zipMessages : Retrieved %d message ids.\n", len(ids))
|
|
i := 0
|
|
for _, id := range ids {
|
|
m, err := getMsg(id)
|
|
logOnError(err, "zipMessages : getMsg")
|
|
if err == nil {
|
|
msgs = append(msgs, *m)
|
|
}
|
|
i = i + 1
|
|
if i%10000 == 0 {
|
|
log.Printf("zipMessages : Exported %d messages.\n", i)
|
|
}
|
|
|
|
}
|
|
|
|
log.Printf("zipMessages : Assigning messages.\n")
|
|
bkp.Messages = msgs
|
|
log.Printf("zipMessages : Marshalling messages.\n")
|
|
b, err := json.Marshal(bkp)
|
|
logOnError(err, "exportMessages : Marshal")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
log.Printf("zipMessages : Compressing messages.\n")
|
|
zbuf := new(bytes.Buffer)
|
|
zw := zip.NewWriter(zbuf)
|
|
zf, err := zw.Create(`backup.json`)
|
|
logOnError(err, "exportMessages : Create")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
_, err = zf.Write(b)
|
|
logOnError(err, "exportMessages : Write")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = zw.Close()
|
|
logOnError(err, "exportMessages : Close")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
log.Printf("zipMessages : Returning messages.\n")
|
|
|
|
return zbuf.Bytes(), nil
|
|
|
|
}
|