Permalink
Browse files

Handle shit a little different.

  • Loading branch information...
1 parent 7817aef commit c7f224deaa1484cea41c8a526c59ad4859107cae @Oshuma committed Feb 17, 2017
Showing with 14 additions and 11 deletions.
  1. +4 −0 scumbag/reddit.go
  2. +6 −11 scumbag/scumbag.go
  3. +4 −0 scumbag/weather.go
View
@@ -20,6 +20,10 @@ func (bot *Scumbag) HandleRedditCommand(channel string, query string) {
if len(args) == 1 {
randomSubredditSubmission(bot, channel, query)
} else {
+ if len(args) == 0 {
+ return
+ }
+
switch args[0] {
case "-t":
subredditSubmission(bot, channel, args[1])
View
@@ -2,7 +2,6 @@ package scumbag
import (
"crypto/tls"
- "errors"
"fmt"
"os"
"strings"
@@ -213,11 +212,7 @@ func (bot *Scumbag) msgHandler(conn *irc.Conn, line *irc.Line) {
func (bot *Scumbag) processCommands(line *irc.Line) {
channel := line.Args[0]
- command, args, err := bot.getCommand(line)
- if err != nil {
- bot.Log.WithField("error", err).Error("processCommands()")
- return
- }
+ command, args := bot.getCommand(line)
switch command {
case CMD_ADMIN:
@@ -241,15 +236,15 @@ func (bot *Scumbag) processCommands(line *irc.Line) {
}
}
-func (bot *Scumbag) getCommand(line *irc.Line) (string, string, error) {
+func (bot *Scumbag) getCommand(line *irc.Line) (string, string) {
fields := strings.Fields(line.Args[1])
+ command := fields[0]
+
if len(fields) > 1 {
- command := fields[0]
args := strings.Join(fields[1:], " ")
-
- return command, args, nil
+ return command, args
} else {
- return "", "", errors.New("getCommand(): Could not get line fields")
+ return command, ""
}
}
View
@@ -75,6 +75,10 @@ func (bot *Scumbag) HandleWeatherCommand(channel string, query string) {
if len(args) == 1 {
currentConditions(bot, channel, args)
} else {
+ if len(args) == 0 {
+ return
+ }
+
switch args[0] {
case "-forecast":
currentForecast(bot, channel, args)

0 comments on commit c7f224d

Please sign in to comment.