twitter

package
v2.37.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 27 Imported by: 0

README

Twitter feeds

Twitter feeds use a scraper because elonmusk closed access to the API.

It is advised to use a proxy for it if you're going to use it for anything more than 10 accounts otherwise you might get ratelimited from twitter.

There is some optional configuration, but the twitter feed should otherwise work without any added config due to defaults set in code.

Optional configuration

YAGPDB_TWITTER_PROXY accepts an http(s) or a sock proxy url, and all requests are sent through it instead of directly hitting twitter, this helps in preventing twitter from blocking your ip. If this isn't set, all requests are direct requests.

YAGPDB_TWITTER_BATCH_SIZE , this is the batch size to split querying to twitter, if you have 100 twitter feeds added, and set this value to 3, then the bot will check for 3 accounts per request.

YAGPDB_TWITTER_POLL_FREQUENCY, Since YAGPDB users scraping, this is the frequency between the total number of records. If you have 100 feeds, and a batch of 3, after all the feeds are polled once, the amount given here in Minutes will be awaited, before restarting polling.

YAGPDB_TWITTER_BATCH_DELAY, this is the delay in Seconds between each batch.

Documentation

Index

Constants

View Source
const TwitterIcon = `` /* 2546-byte string literal not displayed */

Variables

View Source
var DBSchemas = []string{`
CREATE TABLE IF NOT EXISTS twitter_feeds (
	id BIGSERIAL PRIMARY KEY,
	guild_id BIGINT NOT NULL,
	created_at TIMESTAMP WITH TIME ZONE NOT NULL,

	twitter_username TEXT NOT NULL,
	twitter_user_id BIGINT NOT NULL,
	channel_id BIGINT NOT NULL,
	enabled BOOLEAN NOT NULL
);
`, `
CREATE INDEX IF NOT EXISTS twitter_user_id_idx ON twitter_feeds(twitter_user_id);
`, `
ALTER TABLE twitter_feeds ADD COLUMN IF NOT EXISTS include_replies BOOLEAN NOT NULL DEFAULT false;
`, `
ALTER TABLE twitter_feeds ADD COLUMN IF NOT EXISTS include_rt BOOLEAN NOT NULL DEFAULT true;
`,
}
View Source
var PageHTML string

Functions

func KeyLastTweetID added in v2.20.1

func KeyLastTweetID(id string) string

func KeyLastTweetTime added in v2.20.1

func KeyLastTweetTime(id string) string

func RegisterPlugin

func RegisterPlugin()

Types

type ContextKey

type ContextKey int
const (
	ContextKeySub ContextKey = iota
)

type EditForm

type EditForm struct {
	DiscordChannel  int64 `valid:"channel,false"`
	IncludeReplies  bool
	IncludeRetweets bool
	Enabled         bool
}

type Form

type Form struct {
	TwitterUser    string `valid:",1,256"`
	DiscordChannel int64  `valid:"channel,false"`
	ID             int64
}

type Plugin

type Plugin struct {
	Stop chan *sync.WaitGroup
	// contains filtered or unexported fields
}

func (*Plugin) DisableFeed

func (p *Plugin) DisableFeed(elem *mqueue.QueuedElement, err error)

func (*Plugin) HandleEdit

func (p *Plugin) HandleEdit(w http.ResponseWriter, r *http.Request) (templateData web.TemplateData, err error)

func (*Plugin) HandleNew

func (p *Plugin) HandleNew(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func (*Plugin) HandleRemove

func (p *Plugin) HandleRemove(w http.ResponseWriter, r *http.Request) (templateData web.TemplateData, err error)

func (*Plugin) HandleTwitter

func (p *Plugin) HandleTwitter(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func (*Plugin) InitWeb

func (p *Plugin) InitWeb()

func (*Plugin) LoadServerHomeWidget

func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func (*Plugin) OnRemovedPremiumGuild added in v2.17.0

func (p *Plugin) OnRemovedPremiumGuild(guildID int64) error

func (*Plugin) PluginInfo

func (p *Plugin) PluginInfo() *common.PluginInfo

func (*Plugin) StartFeed

func (p *Plugin) StartFeed()

func (*Plugin) Status

func (p *Plugin) Status() (string, string)

func (*Plugin) StopFeed

func (p *Plugin) StopFeed(wg *sync.WaitGroup)

func (*Plugin) WebhookAvatar

func (p *Plugin) WebhookAvatar() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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