Convert to go module, and add logic to delete intro message after member leave or probation expire.
This commit is contained in:
10
go.mod
Normal file
10
go.mod
Normal file
@ -0,0 +1,10 @@
|
||||
module git.nightmare.haus/rudi/disgord-thanos
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.23.2
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/gorilla/sessions v1.2.1
|
||||
github.com/rudi9719/loggy v0.0.0-20201031035735-9438c484de9a
|
||||
)
|
||||
16
go.sum
Normal file
16
go.sum
Normal file
@ -0,0 +1,16 @@
|
||||
github.com/bwmarrin/discordgo v0.23.2 h1:BzrtTktixGHIu9Tt7dEE6diysEF9HWnXeHuoJEt2fH4=
|
||||
github.com/bwmarrin/discordgo v0.23.2/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
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/rudi9719/loggy v0.0.0-20201031035735-9438c484de9a h1:4rkaWoLCWOmra5Mw/dLAWjtDLT/+i5uTX1qhlMVL8WA=
|
||||
github.com/rudi9719/loggy v0.0.0-20201031035735-9438c484de9a/go.mod h1:s1ANCN8bF6HwwTpJLR458MFVGua9oqKKDbph/2jptL4=
|
||||
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=
|
||||
samhofi.us/x/keybase v0.0.0-20200129212102-e05e93be9f3f h1:MHSEiuiRFrFi7BTw46lC22PMk3Fit8IvVRM4xANTt20=
|
||||
samhofi.us/x/keybase v0.0.0-20200129212102-e05e93be9f3f/go.mod h1:fcva80IUFyWcHtV4bBSzgKg07K6Rvuvi3GtGCLNGkyE=
|
||||
11
main.go
11
main.go
@ -31,6 +31,7 @@ var (
|
||||
setupMsg string
|
||||
dg *discordgo.Session
|
||||
lastPM = make(map[string]time.Time)
|
||||
introMsg = make(map[string]string)
|
||||
quotes = []string{"The hardest choices require the strongest wills.", "You're strong, but I could snap my fingers and you'd all cease to exist.", "Fun isn't something one considers when balancing the universe. But this... does put a smile on my face.", "Perfectly balanced, as all things should be.", "I am inevitable."}
|
||||
)
|
||||
|
||||
@ -102,6 +103,7 @@ func runPurge(s *discordgo.Session) {
|
||||
for uid, join := range config.Probations {
|
||||
if time.Since(join) > 2*time.Hour {
|
||||
delete(config.Probations, uid)
|
||||
s.ChannelMessageDelete(config.IntroChann, uid)
|
||||
}
|
||||
}
|
||||
for k, v := range config.Unverified {
|
||||
@ -155,7 +157,7 @@ func runPurge(s *discordgo.Session) {
|
||||
|
||||
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
||||
// Set the playing status.
|
||||
s.UpdateStatus(0, "DreamDaddy v2.1")
|
||||
s.UpdateGameStatus(0, "DreamDaddy v2.2")
|
||||
}
|
||||
|
||||
func guildMemberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) {
|
||||
@ -186,6 +188,7 @@ func guildMemberBanned(s *discordgo.Session, m *discordgo.GuildBanAdd) {
|
||||
for uid := range config.Probations {
|
||||
if m.User.Email == uid {
|
||||
delete(config.Probations, uid)
|
||||
s.ChannelMessageDelete(config.IntroChann, uid)
|
||||
}
|
||||
}
|
||||
saveConfig()
|
||||
@ -201,9 +204,11 @@ func guildMemberRemove(s *discordgo.Session, m *discordgo.GuildMemberRemove) {
|
||||
banned = true
|
||||
s.GuildBanCreateWithReason(config.GuildID, m.User.ID, fmt.Sprintf("Left within 2 hours of joining. %+v", time.Since(join)), 0)
|
||||
delete(config.Probations, uid)
|
||||
s.ChannelMessageDelete(config.IntroChann, uid)
|
||||
}
|
||||
} else {
|
||||
delete(config.Probations, uid)
|
||||
s.ChannelMessageDelete(config.IntroChann, uid)
|
||||
}
|
||||
}
|
||||
s.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("%+v (@%+v) has left, ban: %+v", m.User.ID, m.User.Username, banned))
|
||||
@ -211,6 +216,7 @@ func guildMemberRemove(s *discordgo.Session, m *discordgo.GuildMemberRemove) {
|
||||
for msg, v := range config.Verifications {
|
||||
if v.UserID == m.User.ID {
|
||||
delete(config.Verifications, msg)
|
||||
s.ChannelMessageDelete(config.IntroChann, m.User.ID)
|
||||
}
|
||||
}
|
||||
saveConfig()
|
||||
@ -223,7 +229,8 @@ func verifyMember(s *discordgo.Session, u discordgo.User) {
|
||||
s.GuildMemberRoleRemove(config.GuildID, u.ID, config.MonitorRole)
|
||||
st, _ := s.UserChannelCreate(u.ID)
|
||||
s.ChannelMessageSend(st.ID, "Your verification has been accepted, welcome!")
|
||||
s.ChannelMessageSend(config.IntroChann, fmt.Sprintf("Welcome %+v please introduce yourself! :) feel free to check out <#710557387937022034> to tag your roles. Also please mute any channels you are not interested in!", u.Mention()))
|
||||
id, _ := s.ChannelMessageSend(config.IntroChann, fmt.Sprintf("Welcome %+v please introduce yourself! :) feel free to check out <#710557387937022034> to tag your roles. Also please mute any channels you are not interested in!", u.Mention()))
|
||||
introMsg[id.ID] = u.ID
|
||||
}
|
||||
|
||||
func rejectVerification(s *discordgo.Session, u discordgo.User) {
|
||||
|
||||
Reference in New Issue
Block a user