twitter

package
v0.0.0-...-6769441 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OutOfBand is used for setting the callback URL on the twitter OAuth
	// endpoint
	OutOfBand = "oob"

	// VIPBotHandle is a placeholder which is resolved to the real handle via
	// an environment variable.
	VIPBotHandle = "vip"
	// PartyBotHandle is a placeholder which is resolved to the real handle via
	// an environment variable.
	PartyBotHandle = "party"
)

Variables

This section is empty.

Functions

func AddHandlesToList

func AddHandlesToList(handles []string) error

AddHandlesToList takes a slice of Twitter handles and adds them to the TCR list on Twitter

func CreateSubscription

func CreateSubscription() error

CreateSubscription subscribes the current webhook to the given user

func CreateWebhook

func CreateWebhook() (string, error)

CreateWebhook creates a new webhook and subscribes it to the user, allowing us to receive notifications for new DMs. This should only be used on the TCRPartyVIP bot.

func FilterTweets

func FilterTweets(twitterIDs []string) (*twitter.Stream, error)

FilterTweets will begin filtering tweets and outputting them to the returned channel

func Follow

func Follow(userID int64) error

Follow will create a new friendship with the given user ID

func GetClientFromHandle

func GetClientFromHandle(handle string) (*twitter.Client, *models.OAuthToken, error)

GetClientFromHandle returns a twitter client given a handle constant (ie vip or party) or an explicit twitter handle.

func GetClientFromToken

func GetClientFromToken(oauthToken *models.OAuthToken) *twitter.Client

GetClientFromToken returns a twitter client given an OAuth token

func GetIDFromHandle

func GetIDFromHandle(handle string) (int64, error)

GetIDFromHandle converts a twitter handle into an ID

func GetList

func GetList() (*twitter.Members, error)

GetList fetches the current members of the TCR list on Twitter

func GetListTweets

func GetListTweets(sinceID int64) ([]twitter.Tweet, error)

GetListTweets retrieves a slice of tweets created since the last tweet ID provided

func IsFollower

func IsFollower(userID int64) (bool, error)

IsFollower will return true if the given userID is a follower of the VIP bot

func MonitorRatelimit

func MonitorRatelimit()

MonitorRatelimit will ensure that all twitter calls are executed at most once per two seconds

func RemoveHandlesToList

func RemoveHandlesToList(handles []string) error

RemoveHandlesToList takes a slice of Twitter handles and removes them to the TCR list on Twitter

func Retweet

func Retweet(handle string, tweetID int64) error

Retweet creates a new RT of the given tweet ID

func SendDM

func SendDM(recipientID int64, message string) error

SendDM sends a direct message from the VIP party bot to the specified handle

func SendTweet

func SendTweet(handle string, message string) error

SendTweet sends a new tweet from the given handle constant

func SyncList

func SyncList() error

SyncList will periodically update the Twitter list to ensure it is in sync with our TCR

Types

type OAuthRequest

type OAuthRequest struct {
	Handle       string
	PIN          string
	RequestToken string
}

OAuthRequest collects all required information for completing the OAuth1 authentication flow

func (*OAuthRequest) GetOAuthURL

func (request *OAuthRequest) GetOAuthURL() (string, error)

GetOAuthURL returns a URL that can be used to authenticate a user via the OAuth 1 API

func (*OAuthRequest) ReceivePIN

func (request *OAuthRequest) ReceivePIN() error

ReceivePIN completes the OAuth dance by retrieving user info. Note that it requires the PIN to be set on the OAuthRequest struct.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL