Skip to content

Commit

Permalink
feat: Add maintenance mode handling and update version to 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
monzim committed Oct 19, 2024
1 parent 5b9cbdc commit 5475e6d
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ docs/start.sh
go.work

tmp
*.DS_Store

.env
docs/docker-compose.yml
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main .

FROM alpine:3.19.1

LABEL name="UIU Discord Bot" version="2.0.2"
LABEL name="UIU Discord Bot" version="2.0.3"
LABEL author="Azraf Al Monzim"
LABEL maintainer="Azraf Al Monzim"

Expand Down
5 changes: 5 additions & 0 deletions commands/calender.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ var academyCalenderHandler = Commnad{
},

Handler: func(op *options) {
if true {
in_maintainance(op)
return
}

pf, err := os.Open(CALENDER_PATH)
if err != nil {
op.ses.InteractionRespond(op.in.Interaction, &discordgo.InteractionResponse{
Expand Down
16 changes: 8 additions & 8 deletions commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ func updateUserActivity(db *gorm.DB, userID string) {

var (
commandHandlers = map[string]func(op *options){
ping.Trigger: ping.Handler,
examTime.Trigger: examTime.Handler,
upcomingExam.Trigger: upcomingExam.Handler,
installmentHandler.Trigger: installmentHandler.Handler,
holidayHandler.Trigger: holidayHandler.Handler,
handlerAuthor.Trigger: handlerAuthor.Handler,
handlerVersion.Trigger: handlerVersion.Handler,
academyCalenderHandler.Trigger: academyCalenderHandler.Handler,
ping.Trigger: ping.Handler,
examTime.Trigger: examTime.Handler,
upcomingExam.Trigger: upcomingExam.Handler,
installmentHandler.Trigger: installmentHandler.Handler,
holidayHandler.Trigger: holidayHandler.Handler,
handlerAuthor.Trigger: handlerAuthor.Handler,
handlerVersion.Trigger: handlerVersion.Handler,
// academyCalenderHandler.Trigger: academyCalenderHandler.Handler,
handlerNoticeSearch.Trigger: handlerNoticeSearch.Handler,
helpHandler.Trigger: helpHandler.Handler,
handlerUserConfigure.Trigger: handlerUserConfigure.Handler,
Expand Down
5 changes: 5 additions & 0 deletions commands/holiday.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ var holidayHandler = Commnad{
},

Handler: func(op *options) {
if true {
in_maintainance(op)
return
}

now := time.Now()
var nextHoliday Holiday

Expand Down
5 changes: 5 additions & 0 deletions commands/installment.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ var installmentHandler = Commnad{
},

Handler: func(op *options) {
if true {
in_maintainance(op)
return
}

now := time.Now()
var nextPayment Installment

Expand Down
5 changes: 5 additions & 0 deletions commands/ramadan-calender.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ var handlerRamadanCalender = Commnad{
},

Handler: func(op *options) {
if true {
in_maintainance(op)
return
}

op.ses.InteractionRespond(op.in.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Expand Down
4 changes: 4 additions & 0 deletions commands/upcoming_exam.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ var upcomingExam = Commnad{
},

Handler: func(op *options) {
if true {
in_maintainance(op)
return
}

var embeds []*discordgo.MessageEmbed
for _, e := range upcomingExams {
Expand Down
4 changes: 2 additions & 2 deletions commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/bwmarrin/discordgo"
)

var VERSION = "2.0.2"
var BUILD = time.Date(2024, time.May, 01, 00, 35, 01, 0, time.UTC)
var VERSION = "2.0.3"
var BUILD = time.Date(2024, time.October, 19, 11, 00, 00, 00, time.UTC)

var handlerVersion = Commnad{
Trigger: "version",
Expand Down
12 changes: 12 additions & 0 deletions commands/wating_update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package commands

import "github.com/bwmarrin/discordgo"

func in_maintainance(op *options) {
op.ses.InteractionRespond(op.in.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "This command is on maintainance mode\n" + SUPPORT_STRING,
},
})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.0
require (
github.com/bwmarrin/discordgo v0.27.1
github.com/joho/godotenv v1.5.1
github.com/monzim/uiu-notice-scraper v0.0.0-20240328114953-2266829651b7
github.com/monzim/uiu-notice-scraper v0.0.0-20241019164838-9aa763a64dfb
github.com/rs/zerolog v1.32.0
gorm.io/driver/postgres v1.5.6
gorm.io/gorm v1.25.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/monzim/uiu-notice-scraper v0.0.0-20240328114953-2266829651b7 h1:GXD6Znjv6wj3qU4PHcxCI1+51mq0YIPSQu+WI1DDR8M=
github.com/monzim/uiu-notice-scraper v0.0.0-20240328114953-2266829651b7/go.mod h1:2mSgxkP2CYggskO75zBp/vOKdGoo5J3hzBsn7ZzbYWI=
github.com/monzim/uiu-notice-scraper v0.0.0-20241019164838-9aa763a64dfb h1:lS8pjJyLhEsfyOHIPTAsN5tpxYVcDYsCPiHhVEPipP0=
github.com/monzim/uiu-notice-scraper v0.0.0-20241019164838-9aa763a64dfb/go.mod h1:2mSgxkP2CYggskO75zBp/vOKdGoo5J3hzBsn7ZzbYWI=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down

0 comments on commit 5475e6d

Please sign in to comment.