• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang hipchat.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/andybons/hipchat.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: rockGiphy

func rockGiphy(q string, c *hipchat.Client) {
	log.Printf("Searching for %q", q)
	url := fmt.Sprintf("http://api.giphy.com/v1/gifs/search?q=%s&api_key=dc6zaTOxFJmzC", url.QueryEscape(q))
	resp, err := http.Get(url)
	if err != nil {
		log.Println(err)
		return
	}
	defer resp.Body.Close()
	giphyResp := &struct{ Data []GiphyGif }{}
	dec := json.NewDecoder(resp.Body)
	if err := dec.Decode(giphyResp); err != nil {
		log.Println(err)
		return
	}
	msg := "NO RESULTS. I’M A MONSTER."
	if len(giphyResp.Data) > 0 {
		msg = fmt.Sprintf("%s: %s", q, giphyResp.Data[rand.Intn(len(giphyResp.Data))].Images.Original.URL)
	}

	req := hipchat.MessageRequest{
		RoomId:        *roomName,
		From:          "BUSTER",
		Message:       msg,
		Color:         hipchat.ColorRandom,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}
	if err := c.PostMessage(req); err != nil {
		log.Printf("Expected no error, but got %q", err)
	}
}
开发者ID:poptip,项目名称:buster,代码行数:32,代码来源:buster.go


示例2: hc

func hc(values url.Values) {
	var color, message string

	switch values.Get("Status") {
	case "Up":
		color = getColor(config.UpColor)
		message = formatMessage(values, config.MessageUp)
	case "Down":
		color = getColor(config.DownColor)
		message = formatMessage(values, config.MessageDown)
	}

	c := hipchat.Client{AuthToken: config.AuthToken}
	req := hipchat.MessageRequest{
		RoomId:        config.RoomId,
		From:          config.From,
		Message:       message,
		Color:         color,
		MessageFormat: hipchat.FormatText,
		Notify:        config.Notify,
	}

	if err := c.PostMessage(req); err != nil {
		fmt.Println("Expected no error, but got %q", err)
	}
}
开发者ID:polds,项目名称:ironHipCake,代码行数:26,代码来源:ironHipCake.go


示例3: send

// helper function to send Hipchat requests
func (h *Hipchat) send(color, format, message string) error {
	c := hipchat.Client{AuthToken: h.Token}
	req := hipchat.MessageRequest{
		RoomId:        h.Room,
		From:          "Drone",
		Message:       message,
		Color:         color,
		MessageFormat: format,
		Notify:        true,
	}

	return c.PostMessage(req)
}
开发者ID:rnorth,项目名称:drone,代码行数:14,代码来源:hipchat.go


示例4: SendMessage

func (h HipChatSender) SendMessage(room_id, message string) error {
	c := hipchat.Client{AuthToken: h.AuthToken}
	c.BaseURL = "https://api.hipchat.com/v1"
	req := hipchat.MessageRequest{
		RoomId:        room_id,
		From:          "Amazon SNS",
		Message:       message,
		Color:         hipchat.ColorYellow,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}

	return c.PostMessage(req)
}
开发者ID:aYuMatsuzawa,项目名称:aws-sns-hipchat,代码行数:14,代码来源:main.go


示例5: sendMessageToRoom

func sendMessageToRoom(token, roomID, from, message string, color string) error {
	c := hipchat.Client{AuthToken: token}

	req := hipchat.MessageRequest{
		RoomId:        roomID,
		From:          from,
		Message:       message,
		Color:         color,
		MessageFormat: hipchat.FormatText,
		Notify:        false,
	}

	return c.PostMessage(req)
}
开发者ID:jhannah,项目名称:grim,代码行数:14,代码来源:hipchat.go


示例6: main

func main() {
	c := hipchat.Client{AuthToken: "<PUT YOUR AUTH TOKEN HERE>"}
	req := hipchat.MessageRequest{
		RoomId:        "Rat Man’s Den",
		From:          "GLaDOS",
		Message:       "Bad news: Combustible lemons failed.",
		Color:         hipchat.ColorPurple,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}
	if err := c.PostMessage(req); err != nil {
		log.Printf("Expected no error, but got %q", err)
	}
}
开发者ID:agamatins,项目名称:hipchat,代码行数:14,代码来源:main.go


示例7: notifyPullRequest

func notifyPullRequest(pr github.PullRequest, room string, token string) {
	message := fmt.Sprintf("PR is %d days old: %s", int(time.Since(*pr.CreatedAt).Hours()/24), *pr.HTMLURL)
	client := hipchat.Client{AuthToken: token}
	req := hipchat.MessageRequest{
		RoomId:        room,
		From:          "PR Checker",
		Message:       message,
		Color:         hipchat.ColorRed,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}
	fmt.Println("Sending HipChat notification:", message)
	if err := client.PostMessage(req); err != nil {
		fmt.Println("Failed to send HipChat notification:", err)
	}
}
开发者ID:harryw,项目名称:github-pr-checker,代码行数:16,代码来源:github-pr-checker.go


示例8: Post

// Post posts a hipchat message
// TODO: make hipchat api endpoint configurable for on-premises servers
func (hipChat *HipChat) Post(message string) bool {
	client := hipchat.Client{AuthToken: hipChat.Token}
	req := hipchat.MessageRequest{
		RoomId:        hipChat.RoomID,
		From:          hipChat.From,
		Message:       message,
		Color:         hipchat.ColorPurple,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}
	if err := client.PostMessage(req); err != nil {
		log.Errorf("Failed post message...: %s", message)
		return false
	}
	return true
}
开发者ID:bluele,项目名称:walter,代码行数:18,代码来源:hipchat.go


示例9: HepCat

func HepCat(msg string) (hep string, err error) {
	c := hipchat.Client{AuthToken: ""}
	req := hipchat.MessageRequest{
		RoomId:        "",
		From:          "",
		Message:       msg,
		Color:         hipchat.ColorPurple,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}
	if err := c.PostMessage(req); err != nil {
		log.Printf("Expected no error, but got %q", err)

	}
	return "crap", err
}
开发者ID:entangledphoton,项目名称:Joebot,代码行数:16,代码来源:JoeBot.go


示例10: main

func main() {
	flag.Parse()

	if len(*authToken) == 0 || len(*roomName) == 0 {
		log.Fatal("usage: buster -token=<hipchat token> -room=<room name>")
	}

	lastTime = time.Now()
	c := hipchat.Client{AuthToken: *authToken}

	roomId := ""
	l, err := c.RoomList()
	if err != nil {
		log.Fatalf("RoomList: expected no error, but got %q", err)
	}
	for _, room := range l {
		if strings.ToLower(room.Name) == strings.ToLower(*roomName) {
			roomId = strconv.Itoa(room.Id)
			break
		}
	}
	if len(roomId) == 0 {
		log.Fatalf("No room was found with the name %q", *roomName)
	}
	for {
		time.Sleep(5 * time.Second)
		hist, err := c.RoomHistory(roomId, "recent", "EST")
		if err != nil {
			log.Printf("RoomHistory: Expected no error, but got %q", err)
		}
		for _, m := range hist {
			t, err := m.Time()
			if err != nil {
				log.Println(err)
				continue
			}
			if t.After(lastTime) {
				msg := m.Message
				if strings.HasPrefix(strings.ToLower(msg), cmdPrefix) {
					rockGiphy(msg[len(cmdPrefix):], &c)
				}
				log.Printf("Updating lastTime to %v", t)
				lastTime = t
			}
		}
	}
}
开发者ID:poptip,项目名称:buster,代码行数:47,代码来源:buster.go



注:本文中的github.com/andybons/hipchat.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang model.Project类代码示例发布时间:2022-05-24
下一篇:
Golang cascadia.MustCompile函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap