test
This commit is contained in:
parent
9077f64268
commit
9cf92260e5
31
bot.go
31
bot.go
@ -51,6 +51,7 @@ func BotHandlers(b *tb.Bot) {
|
||||
b.Handle("/vault_item", botVaultItem)
|
||||
|
||||
b.Handle("/restart_job", botRestartJob)
|
||||
b.Handle("/cleanup_job", botCleanupJob)
|
||||
|
||||
b.Handle(tb.OnPhoto, botPhoto)
|
||||
b.Handle(tb.OnChannelPost, botChannelPost)
|
||||
@ -1680,6 +1681,36 @@ func botTimer(m *tb.Message) {
|
||||
return
|
||||
}
|
||||
|
||||
func botCleanupJob(m *tb.Message) {
|
||||
if !m.Private() {
|
||||
return
|
||||
}
|
||||
clt, ok := getLockedClient(m.Chat.ID, false)
|
||||
if !ok {
|
||||
c := TGCommand{
|
||||
Type: commandReplyMsg,
|
||||
Text: "Client not registered",
|
||||
FromMsgID64: int64(m.ID),
|
||||
FromChatID64: m.Chat.ID,
|
||||
}
|
||||
TGCmdQueue <- c
|
||||
return
|
||||
}
|
||||
clt.Mux.Unlock()
|
||||
|
||||
c := TGCommand{
|
||||
Type: commandReplyMsg,
|
||||
Text: "Cleanup started",
|
||||
FromMsgID64: int64(m.ID),
|
||||
FromChatID64: m.Chat.ID,
|
||||
}
|
||||
TGCmdQueue <- c
|
||||
|
||||
cleanupJobData()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func botRestartJob(m *tb.Message) {
|
||||
if !m.Private() {
|
||||
return
|
||||
|
5
cron.go
5
cron.go
@ -17,6 +17,7 @@ func startCron() *cron.Cron {
|
||||
c := cron.New(cron.WithLocation(time.UTC))
|
||||
c.AddFunc("58 6,14,22 * * *", cronSetDef)
|
||||
c.AddFunc("00 0 * * *", cronUpdateAngryBirbs)
|
||||
c.AddFunc("01 0 * * *", cronScrubData)
|
||||
c.AddFunc("02 1,3,5,9,11,13,17,19,21 * * *", cronGetHammerTime)
|
||||
c.AddFunc("12 7,15,23 * * *", cronGetHammerTime)
|
||||
c.AddFunc("13 3,7,11,15,19,23 * * *", cronTribute)
|
||||
@ -50,6 +51,10 @@ func cronUpdateAngryBirbs() {
|
||||
return
|
||||
}
|
||||
|
||||
func cronScrubData() {
|
||||
cleanupJobData()
|
||||
}
|
||||
|
||||
func cronSendWarReport() {
|
||||
muxClients.RLock()
|
||||
for _, c := range clients {
|
||||
|
44
sql.go
44
sql.go
@ -812,7 +812,7 @@ func insertMsgTributesStats(m *ChatWarsMessageTributesStatsAck) error {
|
||||
}
|
||||
|
||||
stmt, err := db.Prepare(`INSERT INTO obj_tribute (tg_user_id, item_id, quantity, exp, date)
|
||||
VALUES (?, ?, ?, ?, ?);`)
|
||||
VALUES (?, ?, ?, ?, ?);`)
|
||||
logOnError(err, "insertMsgTributesStats : Prepare")
|
||||
if err != nil {
|
||||
return err
|
||||
@ -959,3 +959,45 @@ func getSQLListID64(q string) []int64 {
|
||||
|
||||
return ids
|
||||
}
|
||||
|
||||
func cleanupJobData() {
|
||||
var jobID int64
|
||||
jobStmt, err := db.Prepare(`SELECT o.id FROM obj o WHERE o.obj_type_id = ?;`)
|
||||
logOnError(err, "cleanupJobData : prepare jobStmt")
|
||||
if err != nil {
|
||||
jobStmt.Close()
|
||||
return
|
||||
}
|
||||
|
||||
jobs, err := jobStmt.Query(r)
|
||||
err = stmt.QueryRow(jobTypeID64).Scan(&cacheObjType[`job`])
|
||||
logOnError(err, "cleanupJobData : query jobStmt")
|
||||
if err != nil {
|
||||
jobStmt.Close()
|
||||
return
|
||||
}
|
||||
|
||||
for jobs.Next() {
|
||||
err = rows.Scan(&jobID)
|
||||
logOnError(err, "cleanupJobData : scan jobStmt")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
log.Printf("cleanupJobData : JobID : %d\n", jobID)
|
||||
}
|
||||
|
||||
/*
|
||||
for _, id := range ids {
|
||||
job, err := db.Query(`SELECT oj.is_done FROM obj_job oj WHERE oj.obj_id = ?;`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer jobs.Close()
|
||||
stmt, err := db.Prepare(`DELETE FROM obj WHERE id = ?`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stmt.Close()
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user