|
|
|
@ -23,6 +23,7 @@ var (
@@ -23,6 +23,7 @@ var (
|
|
|
|
|
ghostWritingEmoji = "📖" |
|
|
|
|
emf5Emoji = "🚥" |
|
|
|
|
ghostOrbsEmoji = "⚪" |
|
|
|
|
deleteEmoji = "❌" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func init() { |
|
|
|
@ -61,10 +62,17 @@ func ready(s *discordgo.Session, event *discordgo.Ready) {
@@ -61,10 +62,17 @@ func ready(s *discordgo.Session, event *discordgo.Ready) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func readReactions(s *discordgo.Session, m *discordgo.MessageReactionAdd) { |
|
|
|
|
if _, ok := games[m.ChannelID]; !ok { |
|
|
|
|
if m.UserID == s.State.User.ID { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if m.UserID == s.State.User.ID { |
|
|
|
|
if m.Emoji.Name == deleteEmoji { |
|
|
|
|
msg, _ := s.ChannelMessage(m.ChannelID, m.MessageID) |
|
|
|
|
if msg.Author.ID == s.State.User.ID { |
|
|
|
|
s.ChannelMessageDelete(m.ChannelID, m.MessageID) |
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if _, ok := games[m.ChannelID]; !ok { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
fmt.Println("Checking reaction from ", m.UserID) |
|
|
|
@ -109,7 +117,9 @@ func readReactions(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
@@ -109,7 +117,9 @@ func readReactions(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
|
|
|
|
|
} |
|
|
|
|
if len(g.Evidence) == 3 { |
|
|
|
|
s.GuildMemberNickname(m.GuildID, "@me", "") |
|
|
|
|
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v was a %+v", g.Ghost.GhostName, g.PossibleGhosts[0].GhostType)) |
|
|
|
|
msg, _ := s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v was a %+v", g.Ghost.GhostName, g.PossibleGhosts[0].GhostType)) |
|
|
|
|
s.MessageReactionAdd(m.ChannelID, g.PostID, deleteEmoji) |
|
|
|
|
s.MessageReactionAdd(m.ChannelID, msg.ID, deleteEmoji) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
games[m.ChannelID] = g |
|
|
|
@ -128,18 +138,19 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
@@ -128,18 +138,19 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
|
} |
|
|
|
|
g := games[m.ChannelID] |
|
|
|
|
parts := strings.Split(m.Content, " ") |
|
|
|
|
if strings.HasPrefix(m.Content, "!map") { |
|
|
|
|
g.MapName = parts[1] |
|
|
|
|
} |
|
|
|
|
if strings.HasPrefix(m.Content, "!name") { |
|
|
|
|
g.Ghost.GhostName = strings.Join(parts[1:], " ") |
|
|
|
|
s.GuildMemberNickname(m.GuildID, "@me", g.Ghost.GhostName) |
|
|
|
|
} |
|
|
|
|
if strings.HasPrefix(m.Content, "!difficulty") { |
|
|
|
|
g.Difficulty = parts[1] |
|
|
|
|
} |
|
|
|
|
if strings.HasPrefix(m.Content, "!room") { |
|
|
|
|
g.RoomID = parts[1] |
|
|
|
|
if len(parts) == 2 { |
|
|
|
|
g.RoomID = parts[1] |
|
|
|
|
} else { |
|
|
|
|
if g.RoomID != "" { |
|
|
|
|
msg, _ := s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("The room code is `%+v`", g.RoomID)) |
|
|
|
|
s.MessageReactionAdd(m.ChannelID, msg.ID, deleteEmoji) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if strings.HasPrefix(m.Content, "!o") { |
|
|
|
|
if strings.Contains(m.Content, "emf") { |
|
|
|
@ -179,7 +190,45 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
@@ -179,7 +190,45 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
|
g.Objective = append(g.Objective, NoDeaths) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if len(g.Objective) == 3 { |
|
|
|
|
if strings.HasPrefix(m.Content, "!c") { |
|
|
|
|
if strings.Contains(m.Content, "emf") { |
|
|
|
|
g.CompleteObjective(EMF) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "photo") { |
|
|
|
|
g.CompleteObjective(Photo) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "event") { |
|
|
|
|
g.CompleteObjective(Event) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "crucifix") { |
|
|
|
|
g.CompleteObjective(Crucifix) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "motion") { |
|
|
|
|
g.CompleteObjective(Motion) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "clean") { |
|
|
|
|
g.CompleteObjective(SmudgeCleanse) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "hunt") { |
|
|
|
|
g.CompleteObjective(SmudgeHunt) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "salt") { |
|
|
|
|
g.CompleteObjective(Salt) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "candle") { |
|
|
|
|
g.CompleteObjective(Candle) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "sanity") { |
|
|
|
|
g.CompleteObjective(LowSanity) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "escape") { |
|
|
|
|
g.CompleteObjective(MemberEscape) |
|
|
|
|
} |
|
|
|
|
if strings.Contains(m.Content, "death") { |
|
|
|
|
g.CompleteObjective(NoDeaths) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if len(g.Objective) == 3 && g.PostID == "" { |
|
|
|
|
post, _ := s.ChannelMessageSend(m.ChannelID, "The investigation begins! Click below to log evidence.") |
|
|
|
|
g.PossibleGhosts = append(g.PossibleGhosts, ghostTypes...) |
|
|
|
|
g.PostID = post.ID |
|
|
|
@ -193,3 +242,19 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
@@ -193,3 +242,19 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
|
|
|
|
|
|
games[m.ChannelID] = g |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (g *Game) CompleteObjective(objective int) { |
|
|
|
|
var tasks []int |
|
|
|
|
ret := "Current objectives: ```" |
|
|
|
|
for _, v := range g.Objective { |
|
|
|
|
if v != objective { |
|
|
|
|
tasks = append(tasks, v) |
|
|
|
|
ret += fmt.Sprintf("%+v\n", objectiveToStr(v)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ret += "```" |
|
|
|
|
msg, _ := dg.ChannelMessageSend(g.Identifier, ret) |
|
|
|
|
dg.MessageReactionAdd(g.Identifier, msg.ID, deleteEmoji) |
|
|
|
|
g.Objective = tasks |
|
|
|
|
games[g.Identifier] = *g |
|
|
|
|
} |
|
|
|
|