當前位置: 首頁>>代碼示例>>Golang>>正文


Golang twistream.Timeline類代碼示例

本文整理匯總了Golang中github.com/otiai10/twistream.Timeline的典型用法代碼示例。如果您正苦於以下問題:Golang Timeline類的具體用法?Golang Timeline怎麽用?Golang Timeline使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Timeline類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Handle

func (h AddHandler) Handle(tw twistream.Status, tl *twistream.Timeline) error {

	botname := config.V.Twitter.Bot.ScreenName

	user, err := models.FindUserByIdStr(DB(), tw.User.IdStr)
	if err != nil {
		return err
	}

	d := words.Parse(tw.Text).Remove("@"+botname).Remove("/add", "/a")

	user.TODOs = append(user.TODOs, d.Words...)

	user.Update(DB())

	txt := words.New(d.Words...).
		Prepend("@" + tw.User.ScreenName).
		Append("追加しました").
		Join(" ")
	return tl.Tweet(twistream.Status{
		Text:                txt,
		InReplyToScreenName: tw.User.ScreenName,
		InReplyToStatusId:   tw.Id,
	})
}
開發者ID:hisyotan,項目名稱:hisyotan,代碼行數:25,代碼來源:add.go

示例2: Handle

func (h RememberMeHandler) Handle(tw twistream.Status, tl *twistream.Timeline) error {

	user, err := models.FindUserByIdStr(DB(), tw.User.IdStr)
	log.Println(user, err)

	if err == nil {
		txt := words.New("いや、もう知ってますよ...").Prepend("@" + tw.User.ScreenName).Join()
		return tl.Tweet(twistream.Status{
			Text:                txt,
			InReplyToScreenName: tw.User.ScreenName,
			InReplyToStatusId:   tw.Id,
		})
	}

	err = models.SaveNewUser(DB(), models.NewUserFromTwistreamStatus(tw))
	if err != nil {
		return err
	}

	txt := words.New("よろしくおねがいしまーす! 今日も1日がんばるぞい!").Prepend("@" + tw.User.ScreenName).Join()
	return tl.Tweet(twistream.Status{
		Text:                txt,
		InReplyToScreenName: tw.User.ScreenName,
		InReplyToStatusId:   tw.Id,
	})
}
開發者ID:hisyotan,項目名稱:hisyotan,代碼行數:26,代碼來源:rememberme.go

示例3: HandleError

func (h OnErrorHandler) HandleError(err error, tw twistream.Status, tl *twistream.Timeline) error {
	// botname := config.V.Twitter.Bot.ScreenName
	txt := words.Parse("エラー、よく聞き取れませんでした: ").
		Prepend("@otiai10").
		Append(err.Error()).
		Join(" ")
	return tl.Tweet(twistream.Status{
		Text:                txt,
		InReplyToScreenName: tw.User.ScreenName,
		InReplyToStatusId:   tw.Id,
	})
	return err
}
開發者ID:hisyotan,項目名稱:hisyotan,代碼行數:13,代碼來源:onerror.go

示例4: Listen

func Listen(timeline *twistream.Timeline) {
	ch := timeline.Listen()
	for {
		select {
		case tw := <-ch:
			err := matchesAndHandles(tw, timeline)
			if err != nil {
				h := handlers.OnErrorHandler{}
				h.HandleError(err, tw, timeline)
			}
		}
	}
}
開發者ID:hisyotan,項目名稱:hisyotan,代碼行數:13,代碼來源:routes.go

示例5: Handle

func (h EchoHandler) Handle(tw twistream.Status, tl *twistream.Timeline) error {
	botname := config.V.Twitter.Bot.ScreenName
	txt := words.Parse(tw.Text).
		Remove("@" + botname).
		Remove("/echo").
		Prepend("@" + tw.User.ScreenName).
		Append("って何?").
		Join(" ")
	err := tl.Tweet(twistream.Status{
		Text:                txt,
		InReplyToScreenName: tw.User.ScreenName,
		InReplyToStatusId:   tw.Id,
	})
	log.Println(txt, err)
	return err
}
開發者ID:hisyotan,項目名稱:hisyotan,代碼行數:16,代碼來源:echo.go

示例6: Handle

func (h ListHandler) Handle(tw twistream.Status, tl *twistream.Timeline) error {

	user, err := models.FindUserByIdStr(DB(), tw.User.IdStr)
	if err != nil {
		return err
	}

	botname := config.V.Twitter.Bot.ScreenName
	txt := words.New(user.TODOs...).
		Remove("@"+botname).Remove("/add", "/a").
		Prepend("@" + tw.User.ScreenName).
		Append("いちらんです").
		Join(" ")
	return tl.Tweet(twistream.Status{
		Text:                txt,
		InReplyToScreenName: tw.User.ScreenName,
		InReplyToStatusId:   tw.Id,
	})
}
開發者ID:hisyotan,項目名稱:hisyotan,代碼行數:19,代碼來源:list.go

示例7: Handle

func (h HelloHandler) Handle(tw twistream.Status, tl *twistream.Timeline) error {

	user, err := models.FindUserByIdStr(DB(), tw.User.IdStr)
	log.Println(user, err)

	if err == nil {
		txt := words.New("hello! hello!").Prepend("@" + tw.User.ScreenName).Join()
		return tl.Tweet(twistream.Status{
			Text:                txt,
			InReplyToScreenName: tw.User.ScreenName,
			InReplyToStatusId:   tw.Id,
		})
	}

	txt := words.New("誰すか?").Prepend("@" + tw.User.ScreenName).Join()
	return tl.Tweet(twistream.Status{
		Text:                txt,
		InReplyToScreenName: tw.User.ScreenName,
		InReplyToStatusId:   tw.Id,
	})
}
開發者ID:hisyotan,項目名稱:hisyotan,代碼行數:21,代碼來源:hello.go


注:本文中的github.com/otiai10/twistream.Timeline類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。