Skip to content

Commit

Permalink
Merge pull request #61 from niwaniwa/bugfix/emoji-note-system
Browse files Browse the repository at this point in the history
fix: properly reflect values
  • Loading branch information
niwaniwa authored Jul 22, 2023
2 parents 98948f6 + 3318536 commit cae4ea0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
36 changes: 18 additions & 18 deletions emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func GetEmoji(id string) (*Emoji, error) {
return nil, errors.New("emoji not found")
}

func approve(emoji Emoji) {
func (emoji *Emoji) approve() {
if emoji.IsAccepted {
u, _ := Session.User(emoji.RequestUser)
logger.WithFields(debug.Fields{
Expand All @@ -77,19 +77,19 @@ func approve(emoji Emoji) {
}
uploadToMisskey(emoji)
emoji.IsFinish = true
sendDirectMessage(emoji, "申請された絵文字は登録されました。"+emoji.ID)
deleteChannel(emoji)
sendDirectMessage(*emoji, "申請された絵文字は登録されました。"+emoji.ID)
deleteChannel(*emoji)
}

func disapprove(emoji Emoji) {
func (emoji *Emoji) disapprove() {
if emoji.IsAccepted {
return
}

emoji.IsAccepted = false
emoji.IsFinish = true
sendDirectMessage(emoji, "申請された絵文字は却下されました。 "+emoji.ID)
deleteChannel(emoji)
sendDirectMessage(*emoji, "申請された絵文字は却下されました。 "+emoji.ID)
deleteChannel(*emoji)
}

func deleteChannel(emoji Emoji) {
Expand Down Expand Up @@ -125,7 +125,7 @@ func emojiReconstruction() []Emoji {
}
}
emojiProcessList = reconstruction
return reconstruction
return accepted
}

func noteEmojiAdded(emojis []Emoji) {
Expand All @@ -144,24 +144,24 @@ func noteEmojiAdded(emojis []Emoji) {
})
}

func (e Emoji) reset() {
e.RequestState = workflow[0]
e.ResponseState = workflow[0]
e.IsSensitive = false
e.IsAccepted = false
e.IsRequested = false
func (emoji *Emoji) reset() {
emoji.RequestState = workflow[0]
emoji.ResponseState = workflow[0]
emoji.IsSensitive = false
emoji.IsAccepted = false
emoji.IsRequested = false
}

func (e Emoji) abort() {
remove(e)
e.reset()
e.IsFinish = true
func (emoji *Emoji) abort() {
remove(*emoji)
emoji.reset()
emoji.IsFinish = true
}

func remove(val Emoji) {
var newSlice []Emoji
for _, v := range emojiProcessList {
if v != val {
if v.ID != val.ID {
newSlice = append(newSlice, v)
}
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func main() {

defer Session.Close()

ticker := time.NewTicker(24 * time.Hour)
ticker := time.NewTicker(12 * time.Hour)
go func() {
for {
select {
Expand Down
2 changes: 1 addition & 1 deletion misskey.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
)

func uploadToMisskey(e Emoji) error {
func uploadToMisskey(e *Emoji) error {
client, err := misskey.NewClientWithOptions(
misskey.WithAPIToken(misskeyToken),
misskey.WithBaseURL("https", misskeyHost, ""),
Expand Down
4 changes: 2 additions & 2 deletions request-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,14 @@ func emojiModerationReaction(s *discordgo.Session, m *discordgo.MessageReactionA
emoji.DisapproveCount = dsCount

if emoji.DisapproveCount-1 >= roleCount || (isDebug && emoji.DisapproveCount-1 >= 1) {
disapprove(*emoji)
emoji.disapprove()
s.ChannelMessageSend(m.ChannelID, "申請は却下されました")
closeThread(m.ChannelID, emoji.ModerationMessageID)
return
}

if emoji.ApproveCount-1 >= roleCount || (isDebug && emoji.ApproveCount-1 >= 1) {
approve(*emoji)
emoji.approve()
s.ChannelMessageSend(m.ChannelID, "絵文字はアップロードされました")
closeThread(m.ChannelID, emoji.ModerationMessageID)
return
Expand Down

0 comments on commit cae4ea0

Please sign in to comment.