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"
)
//Session for DiscordGo
var Session, _ = discordgo.New()
var testPtr = flag.Bool("test", false, "Test mode")
var bot_token string
var bot_channel string
var botToken string
var botChannel string
func init() {
flag.StringVar(&bot_token, "t", "", "Discord Authentication Token")
flag.StringVar(&bot_channel, "bc", "", "Bot status channel")
flag.StringVar(&botToken, "t", "", "Discord Authentication Token")
flag.StringVar(&botChannel, "bc", "", "Bot status channel")
flag.Parse()
if os.Getenv("DISCORD_TOKEN") != "" {
Session.Token = "Bot " + os.Getenv("DISCORD_TOKEN")
} else {
Session.Token = "Bot " + bot_token
Session.Token = "Bot " + botToken
}
if os.Getenv("DISCORD_BOT_CHANNEL") != "" {
bot_channel = os.Getenv("DISCORD_BOT_CHANNEL")
if os.Getenv("DISCORD_botChannel") != "" {
botChannel = os.Getenv("DISCORD_botChannel")
}
}
@ -61,13 +62,13 @@ func main() {
func ready(s *discordgo.Session, event *discordgo.Ready) {
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.")
s.Close()
os.Exit(0)
}
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) {
@ -104,7 +105,7 @@ func isUserMentioned(m *discordgo.MessageCreate, u *discordgo.User) bool {
func textToButt(m *discordgo.MessageCreate, s *discordgo.Session) string {
cleanmessage, _ := m.ContentWithMoreMentionsReplaced(s)
words := strings.Fields(cleanmessage)
for i, _ := range words {
for i := range words {
if rand.Intn(10) > 7 {
words[i] = "butt"
}