utilities

package
v1.18.13 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: AGPL-3.0 Imports: 27 Imported by: 4

Documentation

Index

Constants

View Source
const (
	OpcodeDispatch = iota
	OpcodeHeartbeat
	OpcodeIdentify
	OpcodePresenceUpdate
	OpcodeVoiceStateUpdate
	OpcodeResume = iota + 1
	OpcodeReconnect
	OpcodeRequestGuildMembers
	OpcodeInvalidSession
	OpcodeHello
	OpcodeHeartbeatACK
)
View Source
const (
	EventNameMessageCreate = "MESSAGE_CREATE"
	EventNameMessageUpdate = "MESSAGE_UPDATE"
	EventNameReady         = "READY"
	EventNameResumed       = "RESUMED"
)
View Source
const UserAgent = "" /* 152-byte string literal not displayed */
View Source
const Useragent = "" /* 143-byte string literal not displayed */
View Source
const XSuper = "" /* 288-byte string literal not displayed */
View Source
const XSuperProp = "" /* 292-byte string literal not displayed */
View Source
const XTrack = "" /* 516-byte string literal not displayed */

Variables

This section is empty.

Functions

func Bypass added in v1.0.5

func Bypass(client *http.Client, serverid string, token string, invite string) error

func CommonHeaders

func CommonHeaders(req *http.Request) *http.Request

func Contains

func Contains(s []string, e string) bool

func DecodeBr added in v1.0.5

func DecodeBr(data []byte) ([]byte, error)

Decoding brotli encrypted responses

func EncodeImg added in v1.0.7

func EncodeImg(pathToImage string) (string, error)

Encoding images to b64

func FindMessage added in v1.0.6

func FindMessage(channel string, messageid string, token string) (string, error)

func GetFiles added in v1.0.7

func GetFiles(dir string) ([]string, error)

Get all file paths in a directory

func GetReactions added in v1.0.7

func GetReactions(channel string, message string, token string, emoji string, after string) ([]string, error)

func HandleOutOfBounds added in v1.7.7

func HandleOutOfBounds()

func ProcessAvatar added in v1.8.0

func ProcessAvatar(av string, memberid string) error

func RandomResult added in v1.8.3

func RandomResult() []string

func ReadBody added in v1.0.6

func ReadBody(resp http.Response) ([]byte, error)

Function to handle all sorts of accepted-encryptions

func ReadLines

func ReadLines(filename string) ([]string, error)

func RegisterHeaders added in v1.0.6

func RegisterHeaders(req *http.Request) *http.Request

func RemoveDuplicateStr added in v1.0.7

func RemoveDuplicateStr(strSlice []string) []string

func RemoveSubset added in v1.0.5

func RemoveSubset(s []string, r []string) []string

Inputs 2 slices of strings and returns a slice of strings which does not contain elements from the second slice

func Ring added in v1.0.7

func Ring(httpClient *http.Client, auth string, snowflake string) (int, error)

func Scrape added in v1.0.7

func Scrape(ws *Connection, Guild string, Channel string, index int) error

func ScrapeOffline added in v1.0.7

func ScrapeOffline(c *Connection, guild string, query string) error

func Snowflake

func Snowflake() int64

func TruncateLines added in v1.0.5

func TruncateLines(filename string, line []string) error

func ValidateBios added in v1.8.0

func ValidateBios(bios []string) []string

func WriteLines

func WriteLines(filename string, line string) error

func XContextGen added in v1.7.9

func XContextGen(guildID string, channelID string, ChannelType float64) (string, error)

Types

type AvatarChange added in v1.0.7

type AvatarChange struct {
	Avatar string `json:"avatar"`
}

type CallData added in v1.0.7

type CallData struct {
	ChannelId string      `json:"channel_id"`
	GuildId   interface{} `json:"guild_id"`
	SelfDeaf  bool        `json:"self_deaf"`
	SelfMute  bool        `json:"self_mute"`
	SelfVideo bool        `json:"self_video"`
}

type CallEvent added in v1.0.7

type CallEvent struct {
	Op   int      `json:"op"`
	Data CallData `json:"d"`
}

type CapmonsterOutResponse added in v1.18.13

type CapmonsterOutResponse struct {
	ErrorID   int      `json:"errorId,omitempty"`
	ErrorCode string   `json:"errorCode,omitempty"`
	Status    string   `json:"status,omitempty"`
	Solution  Solution `json:"solution"`
}

type CapmonsterPayload added in v1.18.13

type CapmonsterPayload struct {
	ClientKey string `json:"clientKey,omitempty"`
	Task      Task   `json:"task,omitempty"`
	TaskId    int    `json:"taskId,omitempty"`
}

type CapmonsterSubmitResponse added in v1.18.13

type CapmonsterSubmitResponse struct {
	ErrorID int `json:"errorId,omitempty"`
	TaskID  int `json:"taskId,omitempty"`
}

type CaptchaSettings added in v1.8.8

type CaptchaSettings struct {
	ClientKey  string `yaml:"captcha_api_key"`
	CaptchaAPI string `yaml:"captcha_api"`
	Timeout    int    `yaml:"max_captcha_wait"`
	MaxCaptcha int    `yaml:"max_captcha_retry"`
}

type ClientState added in v1.0.7

type ClientState struct {
	HighestLastMessageID     string `json:"highest_last_message_id,omitempty"`
	ReadStateVersion         int    `json:"read_state_version,omitempty"`
	UserGuildSettingsVersion int    `json:"user_guild_settings_version,omitempty"`
}

type Config added in v1.0.6

type Config struct {
	DirectMessage      DirectMessage      `yaml:"direct_message_settings"`
	ProxySettings      ProxySettings      `yaml:"proxy_settings"`
	ScraperSettings    ScraperSettings    `yaml:"scraper_settings"`
	CaptchaSettings    CaptchaSettings    `yaml:"captcha_settings"`
	OtherSettings      OtherSettings      `yaml:"other_settings"`
	SuspicionAvoidance SuspicionAvoidance `yaml:"suspicion_avoidance"`
}

func GetConfig added in v1.0.6

func GetConfig() (Config, error)

type Connection added in v1.0.7

type Connection struct {
	Members       []string
	OfflineScrape chan []byte
	AllMembers    []string
	Messages      chan []byte
	Complete      bool
	Conn          *websocket.Conn
	// contains filtered or unexported fields
}

Define WebSocket connection struct

func (*Connection) Close added in v1.0.7

func (c *Connection) Close() error

func (*Connection) Ping added in v1.0.7

func (c *Connection) Ping(interval time.Duration)

func (*Connection) ReadHello added in v1.0.7

func (c *Connection) ReadHello() (int, error)

Read Hello function to read hello message from websocket return 0 if next message is not a hello message or return the heartbeat interval

func (*Connection) WriteJSONe added in v1.0.7

func (c *Connection) WriteJSONe(e *Event) error

Function to write event

func (*Connection) WriteRaw added in v1.0.7

func (c *Connection) WriteRaw(e interface{}) error

Send interface to websocket

type Custom added in v1.0.7

type Custom struct {
	GuildID  interface{} `json:"guild_id"`
	Limit    int         `json:"limit"`
	Query    string      `json:"query"`
	Presence bool        `json:"presence"`
}

type CustomEvent added in v1.0.7

type CustomEvent struct {
	Op   int    `json:"op,omitempty"`
	Data Custom `json:"d,omitempty"`
}

type Data added in v1.0.7

type Data struct {
	Message
	Identify
	ClientState       ClientState            `json:"client_state,omitempty"`
	HeartbeatInterval int                    `json:"heartbeat_interval,omitempty"`
	SessionID         string                 `json:"session_id,omitempty"`
	Sequence          int                    `json:"seq,omitempty"` // For sending only
	GuildId           interface{}            `json:"guild_id,omitempty"`
	Channels          map[string]interface{} `json:"channels,omitempty"`
	Ops               []Ops                  `json:"ops,omitempty"`
	ChannelID         string                 `json:"channel_id,omitempty"`
	Members           []Member               `json:"members,omitempty"`
	Typing            bool                   `json:"typing,omitempty"`
	Threads           bool                   `json:"threads,omitempty"`
	Activities        bool                   `json:"activities,omitempty"`
	ThreadMemberLists interface{}            `json:"thread_member_lists,omitempty"`
}

type DirectMessage added in v1.8.8

type DirectMessage struct {
	Delay      int  `yaml:"individual_delay"`
	LongDelay  int  `yaml:"rate_limit_delay"`
	Offset     int  `yaml:"offset"`
	Skip       bool `yaml:"skip_completed"`
	Call       bool `yaml:"call"`
	Remove     bool `yaml:"remove_dead_tokens"`
	RemoveM    bool `yaml:"remove_completed_members"`
	Stop       bool `yaml:"stop_dead_tokens"`
	Mutual     bool `yaml:"check_mutual"`
	Friend     bool `yaml:"friend_before_DM"`
	Websocket  bool `yaml:"online_tokens"`
	MaxDMS     int  `yaml:"max_dms_per_token"`
	Receive    bool `yaml:"receive_messages"`
	SkipFailed bool `yaml:"skip_failed"`
	Block      bool `yaml:"block_after_dm"`
	Close      bool `yaml:"close_dm_after_message"`
}

type Embed added in v1.0.6

type Embed struct {
	Title string `json:"title,omitempty"`

	// The type of embed. Always EmbedTypeRich for webhook embeds.
	Type        string             `json:"type,omitempty"`
	Description string             `json:"description,omitempty"`
	URL         string             `json:"url,omitempty"`
	Image       *MessageEmbedImage `json:"image,omitempty"`

	// The color code of the embed.
	Color     int                    `json:"color,omitempty"`
	Footer    EmbedFooter            `json:"footer,omitempty"`
	Thumbnail *MessageEmbedThumbnail `json:"thumbnail,omitempty"`
	Provider  EmbedProvider          `json:"provider,omitempty"`
	Author    EmbedAuthor            `json:"author,omitempty"`
	Fields    []EmbedField           `json:"fields,omitempty"`
}

type EmbedAuthor added in v1.0.6

type EmbedAuthor struct {
	Name         string `json:"name,omitempty"`
	URL          string `json:"url,omitempty"`
	IconURL      string `json:"icon_url,omitempty"`
	ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

type EmbedField added in v1.0.6

type EmbedField struct {
	Name   string `json:"name,omitempty"`
	Value  string `json:"value,omitempty"`
	Inline bool   `json:"inline,omitempty"`
}

type EmbedFooter added in v1.0.6

type EmbedFooter struct {
	Text         string `json:"text,omitempty"`
	IconURL      string `json:"icon_url,omitempty"`
	ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

type EmbedProvider added in v1.0.6

type EmbedProvider struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}

type Emoji added in v1.0.6

type Emoji struct {
	ID       string `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	Animated bool   `json:"animated,omitempty"`
}

type Event added in v1.0.7

type Event struct {
	Op        int    `json:"op"`
	Data      Data   `json:"d,omitempty"`
	Sequence  int    `json:"s,omitempty"`
	EventName string `json:"t,omitempty"`
}

type FormField added in v1.7.7

type FormField struct {
	FieldType   string   `json:"field_type"`
	Label       string   `json:"label"`
	Description string   `json:"description"`
	Required    bool     `json:"required"`
	Values      []string `json:"values"`
	Response    bool     `json:"response"`
}

type Guilds added in v1.0.7

type Guilds struct {
	ID string `json:"id"`
}

type Identify added in v1.0.7

type Identify struct {
	Token        string     `json:"token,omitempty"`
	Properties   Properties `json:"properties,omitempty"`
	Capabilities int        `json:"capabilities,omitempty"`
	Compress     bool       `json:"compress,omitempty"`
	Presence     Presence   `json:"presence,omitempty"`
}

type Instance added in v1.0.7

type Instance struct {
	Token        string
	Password     string
	Proxy        string
	Cookie       string
	Fingerprint  string
	Messages     []Message
	Count        int
	LastQuery    string
	LastCount    int
	Members      []User
	AllMembers   []User
	Retry        int
	ScrapeCount  int
	ID           string
	Receiver     bool
	Config       Config
	GatewayProxy string
	Client       *http.Client
	WG           *sync.WaitGroup
	Ws           *Connection
	// contains filtered or unexported fields
}

func (*Instance) AvatarChanger added in v1.0.7

func (in *Instance) AvatarChanger(avatar string) (http.Response, error)

@me Discord Patch request to change Avatar

func (*Instance) BioChanger added in v1.8.0

func (in *Instance) BioChanger(bios []string) error

func (*Instance) BlockUser added in v1.8.0

func (in *Instance) BlockUser(userid string) (int, error)

func (*Instance) Call added in v1.0.7

func (in *Instance) Call(snowflake string) error

func (*Instance) Capmonster added in v1.18.13

func (in *Instance) Capmonster(sitekey, website, rqdata, cookies string) (string, error)

func (*Instance) CheckToken added in v1.0.7

func (in *Instance) CheckToken() int

func (*Instance) CloseDMS added in v1.8.0

func (in *Instance) CloseDMS(snowflake string) (int, error)

func (*Instance) ContextProperties added in v1.7.9

func (in *Instance) ContextProperties(invite, cookie, fingerprint string) (string, error)

func (*Instance) Friend added in v1.0.7

func (in *Instance) Friend(Username string, Discrim int) (*http.Response, error)

func (*Instance) GetCfBm added in v1.8.2

func (in *Instance) GetCfBm(m, r, cookies string) (string, error)

func (*Instance) GetCookieString added in v1.1.0

func (in *Instance) GetCookieString() (string, error)

func (*Instance) GetFingerprintString added in v1.1.0

func (in *Instance) GetFingerprintString(cookie string) (string, error)

Getting Fingerprint to use in our requests for more legitimate seeming requests.

func (*Instance) Invite added in v1.0.7

func (in *Instance) Invite(Code string) error

func (*Instance) Inviter added in v1.8.1

func (in *Instance) Inviter(invitationCode string, mode int, cookie string, fingerprint string) (int, string, string, error)

New Invite joiner

func (*Instance) Leave added in v1.0.7

func (in *Instance) Leave(serverid string) int

func (*Instance) NameChanger added in v1.0.7

func (in *Instance) NameChanger(name string) (http.Response, error)

@me Discord Patch request to change Username

func (*Instance) NewConnection added in v1.7.9

func (in *Instance) NewConnection(fatalHandler func(err error)) (*Connection, error)

Input Discord token and start a new websocket connection

func (*Instance) OpenChannel added in v1.0.7

func (in *Instance) OpenChannel(recepientUID string) (string, error)

func (*Instance) OpenChannelHeaders added in v1.8.7

func (in *Instance) OpenChannelHeaders(req *http.Request, cookie string) *http.Request

func (*Instance) React added in v1.0.7

func (in *Instance) React(channelID string, MessageID string, Emoji string) error

func (*Instance) SendMessage added in v1.0.7

func (in *Instance) SendMessage(channelSnowflake string, memberid string) (http.Response, error)

Inputs the Channel snowflake and sends them the message; outputs the response code for error handling.

func (*Instance) SendMessageHeaders added in v1.8.7

func (in *Instance) SendMessageHeaders(req *http.Request, cookie, recipient string) *http.Request

func (*Instance) ServerCheck added in v1.0.7

func (in *Instance) ServerCheck(serverid string) (int, error)

func (*Instance) SolveCaptcha added in v1.7.9

func (in *Instance) SolveCaptcha(sitekey string, cookie string, rqData string, rqToken string, url string) (string, error)

func (*Instance) StartWS added in v1.0.7

func (in *Instance) StartWS() error

func (*Instance) TypingHeaders added in v1.8.12

func (in *Instance) TypingHeaders(req *http.Request, cookie, snowflake string) *http.Request

func (*Instance) UserInfo added in v1.0.7

func (in *Instance) UserInfo(userid string) (UserInf, error)

type Intent added in v1.0.7

type Intent int
const (
	IntentsGuilds                 Intent = 1 << 0
	IntentsGuildMembers           Intent = 1 << 1
	IntentsGuildBans              Intent = 1 << 2
	IntentsGuildEmojis            Intent = 1 << 3
	IntentsGuildIntegrations      Intent = 1 << 4
	IntentsGuildWebhooks          Intent = 1 << 5
	IntentsGuildInvites           Intent = 1 << 6
	IntentsGuildVoiceStates       Intent = 1 << 7
	IntentsGuildPresences         Intent = 1 << 8
	IntentsGuildMessages          Intent = 1 << 9
	IntentsGuildMessageReactions  Intent = 1 << 10
	IntentsGuildMessageTyping     Intent = 1 << 11
	IntentsDirectMessages         Intent = 1 << 12
	IntentsDirectMessageReactions Intent = 1 << 13
	IntentsDirectMessageTyping    Intent = 1 << 14

	IntentsAllWithoutPrivileged = IntentsGuilds |
		IntentsGuildBans |
		IntentsGuildEmojis |
		IntentsGuildIntegrations |
		IntentsGuildWebhooks |
		IntentsGuildInvites |
		IntentsGuildVoiceStates |
		IntentsGuildMessages |
		IntentsGuildMessageReactions |
		IntentsGuildMessageTyping |
		IntentsDirectMessages |
		IntentsDirectMessageReactions |
		IntentsDirectMessageTyping
	IntentsAll = IntentsAllWithoutPrivileged |
		IntentsGuildMembers |
		IntentsGuildPresences
	IntentsNone Intent = 0
)

Constants for the different bit offsets of intents

type Member added in v1.0.7

type Member struct {
	User User `json:"user,omitempty"`
}

type Message added in v1.0.6

type Message struct {
	Content   string     `json:"content,omitempty"`
	Embeds    []Embed    `json:"embeds,omitempty"`
	Reactions []Reaction `json:"reactions,omitempty"`
	Author    User       `json:"author,omitempty"`
	GuildID   string     `json:"guild_id,omitempty"`
}

func GetMessage added in v1.0.6

func GetMessage() ([]Message, error)

func GetRxn added in v1.0.6

func GetRxn(channel string, messageid string, token string) (Message, error)

type MessageEmbedImage added in v1.0.6

type MessageEmbedImage struct {
	URL      string `json:"url,omitempty"`
	ProxyURL string `json:"proxy_url,omitempty"`
	Width    int    `json:"width,omitempty"`
	Height   int    `json:"height,omitempty"`
}

type MessageEmbedThumbnail added in v1.0.6

type MessageEmbedThumbnail struct {
	URL      string `json:"url,omitempty"`
	ProxyURL string `json:"proxy_url,omitempty"`
	Width    int    `json:"width,omitempty"`
	Height   int    `json:"height,omitempty"`
}

type NameChange added in v1.0.7

type NameChange struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Ops added in v1.0.7

type Ops struct {
	Items []Userinfo  `json:"items,omitempty"`
	Range interface{} `json:"range,omitempty"`
	Op    string      `json:"op,omitempty"`
}

type OtherSettings added in v1.8.8

type OtherSettings struct {
	DisableKL bool `yaml:"disable_keep_alives"`
}

type Presence added in v1.0.7

type Presence struct {
	Status     string   `json:"status,omitempty"`
	Since      int      `json:"since,omitempty"`
	Activities []string `json:"activities,omitempty"`
	AFK        bool     `json:"afk,omitempty"`
}

type Properties added in v1.0.7

type Properties struct {
	OS                     string `json:"os,omitempty"`
	Browser                string `json:"browser,omitempty"`
	Device                 string `json:"device,omitempty"`
	BrowserUserAgent       string `json:"browser_user_agent,omitempty"`
	BrowserVersion         string `json:"browser_version,omitempty"`
	OSVersion              string `json:"os_version,omitempty"`
	Referrer               string `json:"referrer,omitempty"`
	ReferringDomain        string `json:"referring_domain,omitempty"`
	ReferrerCurrent        string `json:"referrer_current,omitempty"`
	ReferringDomainCurrent string `json:"referring_domain_current,omitempty"`
	ReleaseChannel         string `json:"release_channel,omitempty"`
	ClientBuildNumber      int    `json:"client_build_number,omitempty"`
}

type ProxySettings added in v1.8.8

type ProxySettings struct {
	Proxy           string `yaml:"proxy"`
	ProxyFromFile   bool   `yaml:"proxy_from_file"`
	ProxyForCaptcha bool   `yaml:"proxy_for_captcha"`
	ProxyProtocol   string `yaml:"proxy_protocol"`
	GatewayProxy    bool   `yaml:"use_proxy_for_gateway"`
	Timeout         int    `yaml:"timeout"`
}

type Reaction added in v1.0.6

type Reaction struct {
	Emojis Emoji `json:"emoji,omitempty"`
	Count  int   `json:"count,omitempty"`
}

type Reactionx added in v1.0.7

type Reactionx struct {
	ID string `json:"id"`
}

type RingData added in v1.0.7

type RingData struct {
	Recipients interface{} `json:"recipients"`
}

type ScraperSettings added in v1.8.8

type ScraperSettings struct {
	SleepSc         int  `yaml:"online_scraper_delay"`
	ScrapeUsernames bool `yaml:"scrape_usernames"`
	ScrapeAvatars   bool `yaml:"scrape_avatars"`
}

type Solution added in v1.18.13

type Solution struct {
	CaptchaResponse string `json:"gRecaptchaResponse,omitempty"`
}

type SuspicionAvoidance added in v1.8.8

type SuspicionAvoidance struct {
	RandomIndividualDelay  int `yaml:"random_individual_delay"`
	RandomRateLimitDelay   int `yaml:"random_rate_limit_delay"`
	RandomDelayOpenChannel int `yaml:"random_delay_before_dm"`
	TypingVariation        int `yaml:"typing_variation"`
	TypingSpeed            int `yaml:"typing_speed"`
	TypingBase             int `yaml:"typing_base"`
}

type Task added in v1.7.9

type Task struct {
	CaptchaType   string `json:"type,omitempty"`
	WebsiteURL    string `json:"websiteURL,omitempty"`
	WebsiteKey    string `json:"websiteKey,omitempty"`
	IsInvisible   bool   `json:"isInvisible,omitempty"`
	Data          string `json:"data,omitempty"`
	ProxyType     string `json:"proxyType,omitempty"`
	ProxyAddress  string `json:"proxyAddress,omitempty"`
	ProxyPort     int    `json:"proxyPort,omitempty"`
	ProxyLogin    string `json:"proxyLogin,omitempty"`
	ProxyPassword string `json:"proxyPassword,omitempty"`
	UserAgent     string `json:"userAgent,omitempty"`
	Cookies       string `json:"cookies,omitempty"`
}

type User added in v1.0.7

type User struct {
	ID            string `json:"id"`
	Username      string `json:"username"`
	Discriminator string `json:"discriminator"`
	Avatar        string `json:"avatar"`
}

type UserInf added in v1.0.7

type UserInf struct {
	User   User     `json:"user"`
	Mutual []Guilds `json:"mutual_guilds"`
}

type Userinfo added in v1.0.7

type Userinfo struct {
	Member Member `json:"member,omitempty"`
}

type XContext added in v1.7.9

type XContext struct {
	Location            string  `json:"location"`
	LocationGuildID     string  `json:"location_guild_id"`
	LocationChannelID   string  `json:"location_channel_id"`
	LocationChannelType float64 `json:"location_channel_type"`
}

Jump to

Keyboard shortcuts

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