Example #1
0
	"strings"
	"time"

	"github.com/chadev/Chadev_ircbot/meetup"
	"github.com/danryan/hal"
)

// DevTalk contains the dev talk live stream details.
type DevTalk struct {
	Date, URL string
}

var lunchHandler = hear(`is today (devlunch|dev lunch) day\b`, "is today devlunch day", "Tells if today is lunch day, and what the talk is", func(res *hal.Response) error {
	d := time.Now().Weekday().String()
	if d != "Thursday" {
		msg, err := meetup.GetNextMeetup("chadevs")
		if err != nil {
			hal.Logger.Error(err)
			return res.Send("Sorry I was unable to get details on the next dev lunch.  Please check https://meetup.com/chadevs")
		}

		return res.Send(fmt.Sprintf("No, sorry!  %s", msg))
	}

	msg, err := meetup.GetNextMeetup("chadevs")
	if err != nil {
		hal.Logger.Error(err)
		return res.Send("Sorry I was unable to get details on the next dev lunch.  Please check https://meetup.com/chadevs")
	}

	return res.Send(fmt.Sprintf("Yes!  %s", msg))
Example #2
0
		return err
	}

	group := searchGroups(g, name)
	for _, u := range group.Urls {
		if u.Name == "website" || u.Name == "meetup" {
			m := parseMeetupName(u.URL)
			if m != "" {
				group.meetup = m
			}
		}
	}

	var nextEvent string
	if group.meetup != "" {
		nextEvent, err = meetup.GetNextMeetup(group.meetup)
		if err != nil {
			hal.Logger.Errorf("failed fetching event from meetup.com: %v", err)
		}
	}

	var urls []string
	for _, u := range group.Urls {
		urls = append(urls, u.URL)
	}
	ul := strings.Join(urls, ", ")
	res.Send(fmt.Sprintf("Group name: %s URL: %s", group.Name, ul))
	if nextEvent != "" {
		res.Send(nextEvent)
	}