diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml
index c1553bc..895bd5d 100644
--- a/.github/workflows/aws.yml
+++ b/.github/workflows/aws.yml
@@ -53,7 +53,7 @@ jobs:
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
- ECR_REPOSITORY: amongushelper
+ ECR_REPOSITORY: amongusevents
IMAGE_TAG: latest
run: |
# Build a docker container and
@@ -78,13 +78,13 @@ jobs:
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ./.github/workflows/task-definition.json
- container-name: AmongUsHelper
+ container-name: AmongUsEvents
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
- service: AmongUsHelperService
+ service: AmongUsEventsService
cluster: AmongUsBot
wait-for-service-stability: true
diff --git a/.github/workflows/task-definition.json b/.github/workflows/task-definition.json
index 7fe445a..e08f468 100644
--- a/.github/workflows/task-definition.json
+++ b/.github/workflows/task-definition.json
@@ -9,7 +9,7 @@
"logDriver": "awslogs",
"secretOptions": null,
"options": {
- "awslogs-group": "/ecs/AmongUsHelperTask",
+ "awslogs-group": "/ecs/AmongUsEventsTask",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
@@ -51,7 +51,7 @@
"dockerLabels": null,
"systemControls": null,
"privileged": null,
- "name": "AmongUsHelper"
+ "name": "AmongUsEvents"
}
],
"placementConstraints": [],
@@ -61,8 +61,8 @@
"EC2",
"FARGATE"
],
- "taskDefinitionArn": "arn:aws:ecs:us-east-1:{REPLACE.AccountId}:task-definition/AmongUsHelperTask:4",
- "family": "AmongUsHelperTask",
+ "taskDefinitionArn": "arn:aws:ecs:us-east-1:{REPLACE.AccountId}:task-definition/AmongUsEventsTask:1",
+ "family": "AmongUsEventsTask",
"requiresAttributes": [
{
"targetId": null,
diff --git a/Dockerfile b/Dockerfile
index ee61a28..118e301 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,14 +1,14 @@
FROM golang:alpine as builder
-WORKDIR /amongushelper
+WORKDIR /amongusevents
COPY . .
-RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /amongushelper/main
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /amongusevents/main
FROM scratch
-COPY --chown=65534:0 --from=builder /amongushelper/main /
+COPY --chown=65534:0 --from=builder /amongusevents/main /
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
diff --git a/README.md b/README.md
index 84b09ba..6e0c0f8 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Among Us Helper - Discord Bot
+# Among Us Events - Discord Bot
A discord bot for organizing and planning among us games. This bot was born out of the pain of trying to organize weekly discord games with a group of friends. The bot allows the organizer to create an event in a given discord channel. Users of this discord server can rsvp to the event with 3 options (accept,decline,change time request).
@@ -7,7 +7,7 @@ A discord bot for organizing and planning among us games. This bot was born out
Visit and authorize the bot to your discord server:
- https://discord.com/oauth2/authorize?client_id=758468803583279114&scope=bot&permissions=8
+ https://discord.com/oauth2/authorize?client_id=779556729343049729&scope=bot&permissions=485440
Once the bot is authorized and added to your discord server you will need to create a discord role called ``amongusbot`` the privileges of this role do not matter so you can make them as you see fit.
diff --git a/amongusevents/amongusevents.go b/amongusevents/amongusevents.go
index 7ef867f..f015cc7 100644
--- a/amongusevents/amongusevents.go
+++ b/amongusevents/amongusevents.go
@@ -22,7 +22,7 @@ func CreateEvent(session *discordgo.Session, title string, channelID string) err
Title: title,
Color: 15105570,
Author: &discordgo.MessageEmbedAuthor{
- Name: "Among Us Helper Bot",
+ Name: "Among Us Events Bot",
IconURL: "https://i.imgur.com/Mf4Rj0T.png",
},
Description: "\u200B\n",
@@ -136,7 +136,7 @@ func (s *amongUsEventState) updateEmbedMessageFromState(session *discordgo.Sessi
Title: s.eventTitle,
Color: 15105570,
Author: &discordgo.MessageEmbedAuthor{
- Name: "Among Us Helper Bot",
+ Name: "Among Us Events Bot",
IconURL: "https://i.imgur.com/Mf4Rj0T.png",
},
Description: "\u200B\n",
diff --git a/amongushandlers/amongushandlers.go b/amongushandlers/amongushandlers.go
index 24bacaf..71dabfb 100644
--- a/amongushandlers/amongushandlers.go
+++ b/amongushandlers/amongushandlers.go
@@ -2,10 +2,11 @@ package amongushandlers
import (
"fmt"
+ "net/url"
"strings"
"github.com/bwmarrin/discordgo"
- "github.com/cbyst/AmongUsHelper/amongusevents"
+ "github.com/cbyst/AmongUsEvents/amongusevents"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
@@ -15,6 +16,16 @@ func AttachHandlers(discordSession *discordgo.Session) {
discordSession.AddHandler(commandHandler)
discordSession.AddHandler(messageReactionAddHandle)
discordSession.AddHandler(messageReactionRemoveHandle)
+ discordSession.AddHandler(serverBotAddHandler)
+ discordSession.AddHandler(serverBotRemoveHandler)
+}
+
+func serverBotAddHandler(s *discordgo.Session, g *discordgo.GuildCreate) {
+ log.Infof("Discord Server %s added the AmongUsEvents bot", g.Name)
+}
+
+func serverBotRemoveHandler(s *discordgo.Session, g *discordgo.GuildDelete) {
+ log.Infof("Discord Server %s removed AmongUsEvents bot", g.Name)
}
func messageReactionRemoveHandle(s *discordgo.Session, m *discordgo.MessageReactionRemove) {
@@ -80,9 +91,13 @@ func messageReactionAddHandle(s *discordgo.Session, m *discordgo.MessageReaction
log.Error(errors.WithMessage(err, "Error resyncing event state in reaction add handler for change time reaction event"))
}
} else {
- err = s.MessageReactionRemove(m.MessageReaction.ChannelID, m.MessageReaction.MessageID, m.MessageReaction.Emoji.Name, m.MessageReaction.UserID)
+ reactionID := m.MessageReaction.Emoji.Name
+ if m.MessageReaction.Emoji.ID != "" {
+ reactionID = url.QueryEscape(fmt.Sprintf("<:%s:%s", m.MessageReaction.Emoji.Name, m.MessageReaction.Emoji.ID))
+ }
+ err = s.MessageReactionRemove(m.MessageReaction.ChannelID, m.MessageReaction.MessageID, reactionID, m.MessageReaction.UserID)
if err != nil {
- log.Error(errors.WithMessage(err, fmt.Sprintf("Error removing unsupported reactio in message reaction add handler for %s reaction event", m.MessageReaction.Emoji.Name)))
+ log.Error(errors.WithMessage(err, fmt.Sprintf("Error removing unsupported reaction in message reaction add handler for %s reaction event", m.MessageReaction.Emoji.Name)))
}
}
}
@@ -93,24 +108,27 @@ func commandHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
return
}
- // Check if user is privileged to command the bot
- userIsPrivledged, err := isUserPrivleged(s, m.Author.ID, m.GuildID)
- if err != nil {
- log.Error(errors.WithMessage(err, "Issue checking if user is privileged in command handler"))
- }
-
- // Ignore message if user is not privileged to command bot
- if !userIsPrivledged {
- return
- }
-
// Check message for for command prefix to determine if the message is relevant to the bot
if strings.HasPrefix(m.Content, "!CreateAmongEvent ") {
- title := strings.Trim(strings.TrimPrefix(m.Content, "!CreateAmongEvent "), "\"")
-
- err = amongusevents.CreateEvent(s, title, m.ChannelID)
+ // Check if user is privileged to command the bot
+ userIsPrivledged, err := isUserPrivleged(s, m.Author.ID, m.GuildID)
if err != nil {
- log.Error(errors.WithMessage(err, "Error creating event in create event command handler"))
+ log.Error(errors.WithMessage(err, "Issue checking if user is privileged in command handler"))
+ }
+
+ // Ignore message if user is not privileged to command bot
+ if !userIsPrivledged {
+ s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<@%s> You do not have access to create Among Us Events. To create events you need the amongusbot role.", m.Author.ID))
+ // tell users there not permissioned for this
+ return
+ } else {
+ title := strings.Trim(strings.TrimPrefix(m.Content, "!CreateAmongEvent "), "\"")
+
+ log.Infof("Creating new among event with title: %s for user: %s", title, m.Author.Username)
+ err = amongusevents.CreateEvent(s, title, m.ChannelID)
+ if err != nil {
+ log.Error(errors.WithMessage(err, "Error creating event in create event command handler"))
+ }
}
}
}
diff --git a/go.mod b/go.mod
index 2bc12ce..5b04f0b 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module github.com/cbyst/AmongUsHelper
+module github.com/cbyst/AmongUsEvents
go 1.15
diff --git a/go.sum b/go.sum
index 8fd75ed..2ca13f4 100644
--- a/go.sum
+++ b/go.sum
@@ -1,13 +1,16 @@
github.com/bwmarrin/discordgo v0.22.0 h1:uBxY1HmlVCsW1IuaPjpCGT6A2DBwRn0nvOguQIxDdFM=
github.com/bwmarrin/discordgo v0.22.0/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
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=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
+github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 h1:y6ce7gCWtnH+m3dCjzQ1PCuwl28DDIc3VNnvY29DlIA=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
diff --git a/main.go b/main.go
index 37c4299..8869131 100644
--- a/main.go
+++ b/main.go
@@ -8,7 +8,7 @@ import (
"syscall"
"github.com/bwmarrin/discordgo"
- "github.com/cbyst/AmongUsHelper/amongushandlers"
+ "github.com/cbyst/AmongUsEvents/amongushandlers"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
@@ -24,7 +24,7 @@ func main() {
if *logDebug {
log.SetLevel(log.DebugLevel)
} else {
- log.SetLevel(log.WarnLevel)
+ log.SetLevel(log.InfoLevel)
}
// Check for required token
@@ -49,7 +49,7 @@ func main() {
os.Exit(1)
}
- fmt.Println("Among Us Helper is now running. Press CTRL-C to exit.")
+ fmt.Println("Among Us Events is now running. Press CTRL-C to exit.")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc