Learned how to use golint

pull/8/head
pocketjawa 2019-08-17 15:28:43 -04:00
parent 2fc254901d
commit 83476b3862
1 changed files with 11 additions and 10 deletions

View File

@ -12,22 +12,23 @@ import (
"syscall" "syscall"
) )
//Session for DiscordGo
var Session, _ = discordgo.New() var Session, _ = discordgo.New()
var testPtr = flag.Bool("test", false, "Test mode") var testPtr = flag.Bool("test", false, "Test mode")
var bot_token string var botToken string
var bot_channel string var botChannel string
func init() { func init() {
flag.StringVar(&bot_token, "t", "", "Discord Authentication Token") flag.StringVar(&botToken, "t", "", "Discord Authentication Token")
flag.StringVar(&bot_channel, "bc", "", "Bot status channel") flag.StringVar(&botChannel, "bc", "", "Bot status channel")
flag.Parse() flag.Parse()
if os.Getenv("DISCORD_TOKEN") != "" { if os.Getenv("DISCORD_TOKEN") != "" {
Session.Token = "Bot " + os.Getenv("DISCORD_TOKEN") Session.Token = "Bot " + os.Getenv("DISCORD_TOKEN")
} else { } else {
Session.Token = "Bot " + bot_token Session.Token = "Bot " + botToken
} }
if os.Getenv("DISCORD_BOT_CHANNEL") != "" { if os.Getenv("DISCORD_botChannel") != "" {
bot_channel = os.Getenv("DISCORD_BOT_CHANNEL") botChannel = os.Getenv("DISCORD_botChannel")
} }
} }
@ -61,13 +62,13 @@ func main() {
func ready(s *discordgo.Session, event *discordgo.Ready) { func ready(s *discordgo.Session, event *discordgo.Ready) {
if *testPtr == true { if *testPtr == true {
s.ChannelMessageSend(bot_channel, "Test complete: discord-buttsbot-go") s.ChannelMessageSend(botChannel, "Test complete: discord-buttsbot-go")
log.Printf("Test successful! Now quiting.") log.Printf("Test successful! Now quiting.")
s.Close() s.Close()
os.Exit(0) os.Exit(0)
} }
s.UpdateStatus(0, "with butts!") s.UpdateStatus(0, "with butts!")
s.ChannelMessageSend(bot_channel, "This isn't a butt...") s.ChannelMessageSend(botChannel, "This isn't a butt...")
} }
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
@ -104,7 +105,7 @@ func isUserMentioned(m *discordgo.MessageCreate, u *discordgo.User) bool {
func textToButt(m *discordgo.MessageCreate, s *discordgo.Session) string { func textToButt(m *discordgo.MessageCreate, s *discordgo.Session) string {
cleanmessage, _ := m.ContentWithMoreMentionsReplaced(s) cleanmessage, _ := m.ContentWithMoreMentionsReplaced(s)
words := strings.Fields(cleanmessage) words := strings.Fields(cleanmessage)
for i, _ := range words { for i := range words {
if rand.Intn(10) > 7 { if rand.Intn(10) > 7 {
words[i] = "butt" words[i] = "butt"
} }