Versions in this module Expand all Collapse all v0 v0.0.2 Jul 23, 2023 Changes in this version + const FlagCensored + var ErrRequestFailed = errors.New("request failed") + func BoolZeroOrOne(b bool) string type API + func (api *API) CheckUsername(username string) (ok bool, notOkReasons []string, err error) + func (api *API) GetBackground(username string) (background MessageBackground, err error) + func (api *API) GetStyle(username string) (style MessageStyle, err error) + func (api *API) SetBackground(background MessageBackground) (err error) + func (api *API) SetStyle(style MessageStyle) (err error) type Group + UserID int + type GroupsList struct + Groups [][2]string + RecentGroups [][2]string + UnreadMessages int + func (mg GroupsList) GetGroups() map[string]string + func (mg GroupsList) GetRecentGroups() map[string]string type Message + func (m *Message) IsCensored() bool + type MessageBackground struct + Align string + Alpha int + Color string + HasRecording int64 + ImageAlpha int + IsVid bool + Tile bool + UseImage bool + func (mb *MessageBackground) GetForm() url.Values + type MessageStyle struct + Bold bool + FontFamily string + FontSize string + Italics bool + NameColor string + StylesOn bool + TextColor string + Underline bool + UseBackground string + func (mb MessageStyle) GetForm() url.Values type Participant + UserID int type Persistence + func (p *Persistence) StartAutoSave(ctx context.Context) v0.0.1 Jul 15, 2023 Changes in this version + const API_TIMEOUT + const BASE_BACKOFF_DUR + const BOT_DATA_KEY + const Charset + const CombineFilterAnd + const CombineFilterOr + const CombineFilterXor + const DEFAULT_COLOR + const DEFAULT_TEXT_FONT + const DEFAULT_TEXT_SIZE + const EVENT_BUFFER_SIZE + const EndFrame + const FlagBackground + const FlagBlueChannel + const FlagMedia + const FlagModChannel + const FlagModIcon + const FlagPremium + const FlagRedChannel + const FlagStaffIcon + const MAX_BACKOFF_DUR + const MAX_MESSAGE_HISTORY + const MAX_RETRIES + const MSG_LENGTH_DEFAULT + const MSG_LENGTH_SHORT + const PING_INTERVAL + const PM_SERVER + const SYNC_SEND_TIMEOUT + const WEBSOCKET_ORIGIN + var AnonSeedRe = regexp.MustCompile(`<n\d{4}/>`) + var ErrAddModFailed = errors.New("clear failed") + var ErrAlreadyConnected = errors.New("already connected") + var ErrBadAlias = errors.New("bad alias") + var ErrBadLogin = errors.New("bad login") + var ErrCLimited = errors.New("climited") + var ErrClearFailed = errors.New("clear failed") + var ErrConnectionClosed = errors.New("connection closed") + var ErrFloodBanned = errors.New("flood banned") + var ErrFloodWarning = errors.New("flood warning") + var ErrGCMRegFailed = errors.New("GCM register failed") + var ErrGCMUnregFailed = errors.New("GCM unregister failed") + var ErrInvalidArgument = errors.New("invalid argument") + var ErrInvalidResponse = errors.New("invalid response") + var ErrInvalidUsername = errors.New("invalid username") + var ErrLoginFailed = errors.New("failed to login") + var ErrMessageLength = errors.New("message length exceeded") + var ErrMustLogin = errors.New("must login") + var ErrNoArgument = errors.New("no argument") + var ErrNonSenseWarning = errors.New("nonsense warning") + var ErrNotAGroup = errors.New("not a group") + var ErrNotConnected = errors.New("not connected") + var ErrOfflineLimit = errors.New("offline message limit") + var ErrPremiumExpired = errors.New("premium expired") + var ErrProxyBanned = errors.New("proxy banned") + var ErrRateLimited = errors.New("rate limited") + var ErrRemoveModFailed = errors.New("clear failed") + var ErrRestricted = errors.New("restricted") + var ErrRetryEnds = errors.New("connection closed") + var ErrSetTokenFailed = errors.New("settoken failed") + var ErrShortWarning = errors.New("short warning") + var ErrSpamWarning = errors.New("spam warning") + var ErrTimeout = errors.New("timeout") + var ErrUpdateFailed = errors.New("update failed") + var ErrUpdateModFailed = errors.New("clear failed") + var ErrVerificationRequired = errors.New("verification required") + var FontStyleRe = regexp.MustCompile(`<f x([\da-fA-F]+)?="([\d\w]+)?">`) + var GroupPermissions = map[string]int64 + var GroupStatuses = map[string]int64 + var HtmlTagRe = regexp.MustCompile(`<.*?>`) + var ModactionTmpl = map[string]string + var NameColorRe = regexp.MustCompile(`<n([\da-fA-F]{1,6})\/>`) + var NameFontTag = regexp.MustCompile(`<[nf][^>]*>`) + var PrivateFontStyleRe = regexp.MustCompile(`<g x(\d+)?s([\da-fA-F]+)?="([\d\w]+)?">`) + func ComputeFlagChanges(oldFlags, newFlags int64) (addedFlags, removedFlags int64) + func Contains(arr []T, item T) bool + func CopyMap(src, dst map[K]V) + func CreateAnonSeed(name, sid string) (seed string) + func FileExists(filename string) bool + func FindClosestMatch(source []string, target string) (match string, ratio float64) + func GenerateRandomString(length int) string + func GetAnonName(seed, sid string) (name string) + func GetServer(name string) string + func IsDigit(strnum string) bool + func Max(a T, b ...T) (c T) + func Min(a T, b ...T) (c T) + func ParseTime(strtime string) (t time.Time, err error) + func Remove(arr []T, item T) []T + func SaveConfig(filename string, config *Config) error + func SplitTextIntoChunks(text string, chunkSize int) (chunks []string) + type API struct + Password string + Username string + func (api *API) GetBackgroundInfo(username string) (info BackgroundInfo, err error) + func (api *API) GetCookie(cookiename string) (cookie string, ok bool) + func (api *API) GetFullProfile(username string) (profile FullProfile, err error) + func (api *API) GetGroupList() (groups MyChatGroups, err error) + func (api *API) GetMiniProfile(username string) (profile MiniProfile, err error) + func (api *API) GetToken(gcmID string) (token string, err error) + func (api *API) Initialize() (err error) + func (api *API) IsGroup(groupname string) (answer bool, err error) + func (api *API) RegisterGCM(gcmID, token string) (err error) + func (api *API) SearchPeople(query PeopleQuery) (usernames [][2]string, err error) + func (api *API) UnregisterGCM(gcmID string) (err error) + type Application struct + API *API + Config *Config + Groups SyncMap[string, *Group] + Persistence *Persistence + Private Private + func New(config *Config) *Application + func (app *Application) AddHandler(handler Handler) *Application + func (app *Application) ConnectPM() error + func (app *Application) DisconnectPM() + func (app *Application) Dispatch(event *Event) + func (app *Application) Initialize() + func (app *Application) JoinGroup(groupName string) error + func (app *Application) LeaveGroup(groupName string) error + func (app *Application) Park() + func (app *Application) RemoveHandler(handler Handler) + func (app *Application) Start(ctx context.Context) + func (app *Application) Stop() + type BackgroundInfo struct + Align string + Alpha int + Color string + HasRecording int64 + ImageAlpha int + IsVid bool + Tile bool + UseImage bool + type Backoff struct + Duration time.Duration + MaxDuration time.Duration + func (b *Backoff) Cancel() + func (b *Backoff) Sleep(ctx context.Context) bool + type BanWord struct + WholeWords string + Words string + func (bw *BanWord) GetPartial() []string + func (bw *BanWord) GetWhole() []string + func (bw *BanWord) SetPartial(partial []string) + func (bw *BanWord) SetWhole(exact []string) + type BirthDate time.Time + func (c *BirthDate) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error + type Blocked struct + Blocker string + IP string + ModerationID string + Target string + Time time.Time + type Callback func(*Event, *Context) + type ChatFilter struct + Chats []string + func (f *ChatFilter) Add(chatName string) + func (f *ChatFilter) And(filter Filter) Filter + func (f *ChatFilter) Check(event *Event) bool + func (f *ChatFilter) Not() Filter + func (f *ChatFilter) Or(filter Filter) Filter + func (f *ChatFilter) Remove(chatName string) + func (f *ChatFilter) Xor(filter Filter) Filter + type CombineFilter struct + Left Filter + Mode int + Right Filter + func (f *CombineFilter) And(filter Filter) Filter + func (f *CombineFilter) Check(event *Event) bool + func (f *CombineFilter) Not() Filter + func (f *CombineFilter) Or(filter Filter) Filter + func (f *CombineFilter) Xor(filter Filter) Filter + type CommandHandler struct + Callback Callback + Commands []string + Filter Filter + func (ch *CommandHandler) Check(event *Event) bool + func (ch *CommandHandler) Invoke(event *Event, context *Context) + type Config struct + AnonName string + Debug bool + EnableBG bool + EnablePM bool + Groups []string + NameColor string + Password string + Prefix string + SessionID string + TextColor string + TextFont string + TextSize int + Username string + func LoadConfig(filename string) (*Config, error) + type Context struct + App *Application + BotData *SyncMap[string, any] + ChatData *SyncMap[string, any] + type Event struct + Argument string + Arguments []string + Blocked *Blocked + Command string + Error any + FlagAdded int64 + FlagRemoved int64 + Group *Group + GroupInfo *GroupInfo + IsPrivate bool + Message *Message + ModGrantedAccess int64 + ModRevokedAccess int64 + Participant *Participant + Private *Private + Type EventType + Unblocked *Unblocked + User *User + WithArgument bool + type EventType int64 + const OnAllUserUnbanned + const OnAnnouncement + const OnClearAll + const OnError + const OnFlagUpdate + const OnGroupJoined + const OnGroupLeft + const OnGroupReconnected + const OnJoin + const OnLeave + const OnLogin + const OnLogout + const OnMessage + const OnMessageDelete + const OnMessageHistory + const OnMessageUpdate + const OnModeratorAdded + const OnModeratorRemoved + const OnModeratorUpdated + const OnParticipantCountChange + const OnPrivateConnected + const OnPrivateDisconnected + const OnPrivateFriendActive + const OnPrivateFriendIdle + const OnPrivateFriendOffline + const OnPrivateFriendOnline + const OnPrivateFriendOnlineApp + const OnPrivateKickedOff + const OnPrivateMessage + const OnPrivateOfflineMessage + const OnPrivateReconnected + const OnStart + const OnStop + const OnUpdateGroupInfo + const OnUpdateUserProfile + const OnUserBanned + const OnUserUnbanned + type Filter interface + And func(Filter) Filter + Check func(*Event) bool + Not func() Filter + Or func(Filter) Filter + Xor func(Filter) Filter + func NewChatFilter(groupnames ...string) Filter + func NewRegexFilter(pattern string) Filter + func NewUserFilter(usernames ...string) Filter + type FullProfile struct + Body QueryEscaped + T string + XMLName xml.Name + type Group struct + AnonCount int + AnonName string + App *Application + Channel int64 + Connected bool + Flag int64 + LoggedIn bool + LoginIp string + LoginName string + LoginTime time.Time + MaxMessageLength int + Messages OrderedSyncMap[string, *Message] + Moderators SyncMap[string, int64] + Name string + NameColor string + Owner string + ParticipantCount int64 + Participants SyncMap[string, *Participant] + PremiumExpireAt time.Time + RateLimit time.Duration + RateLimited time.Time + Restrict time.Time + SessionID string + TempMessageIds SyncMap[string, string] + TempMessages SyncMap[string, *Message] + TextColor string + TextFont string + TextSize int + TimeDiff time.Duration + UserCount int + Version [2]int + WsUrl string + func (g *Group) AddModerator(username string, access int64) (err error) + func (g *Group) BanUser(message *Message) (err error) + func (g *Group) ClearAll() (err error) + func (g *Group) Connect(ctx context.Context) (err error) + func (g *Group) Delete(message *Message) (err error) + func (g *Group) DeleteAll(message *Message) (err error) + func (g *Group) Disconnect() + func (g *Group) GetAnnouncement() (annc string, enabled bool, interval time.Duration, err error) + func (g *Group) GetBanList(offset time.Time, ammount int) (banList []Blocked, err error) + func (g *Group) GetBanWords() (banWord BanWord, err error) + func (g *Group) GetContext() context.Context + func (g *Group) GetLastUserMessage(username string) (msg *Message, ok bool) + func (g *Group) GetModActions(dir string, offset int) (modactions []*ModAction, err error) + func (g *Group) GetParticipantsStart() (p *SyncMap[string, *Participant], err error) + func (g *Group) GetParticipantsStop() error + func (g *Group) GetPremiumInfo() (flag int, expire time.Time, err error) + func (g *Group) GetRateLimit() (rate, current time.Duration, err error) + func (g *Group) GetUnbanList(offset time.Time, ammount int) (unbanList []Unblocked, err error) + func (g *Group) IsRestricted() bool + func (g *Group) Login(username, password string) (err error) + func (g *Group) Logout() (err error) + func (g *Group) ProfileRefresh() error + func (g *Group) PropagateEvent(frame string) + func (g *Group) Reconnect() (err error) + func (g *Group) RemoveModerator(username string) (err error) + func (g *Group) SearchBannedUser(query string) (banned Blocked, ok bool) + func (g *Group) Send(args ...string) error + func (g *Group) SendMessage(text string) (msg *Message, err error) + func (g *Group) SendMessageChunked(text string, chunkSize int) (msgs []*Message, err error) + func (g *Group) SetAnnouncement(annc string, enable bool, interval time.Duration) (err error) + func (g *Group) SetBackground(enable bool) (err error) + func (g *Group) SetBanWords(banWord BanWord) (err error) + func (g *Group) SetMedia(enable bool) (err error) + func (g *Group) SetRateLimit(interval time.Duration) (rate time.Duration, err error) + func (g *Group) SyncSend(cb func(string) bool, text ...string) error + func (g *Group) SyncSendWithTimeout(callback func(string) bool, timeout time.Duration, args ...string) (err error) + func (g *Group) UnbanAll() (err error) + func (g *Group) UnbanUser(blocked *Blocked) (err error) + func (g *Group) UpdateGroupFlag(addition, removal int64) (err error) + func (g *Group) UpdateModerator(username string, access int64) (err error) + type GroupInfo struct + OwnerMessage string + Title string + func (gi *GroupInfo) GetMessage() string + func (gi *GroupInfo) GetTitle() string + type Handler interface + Check func(*Event) bool + Invoke func(*Event, *Context) + func NewCommandHandler(callback Callback, filter Filter, commands ...string) Handler + func NewMessageHandler(callback Callback, filter Filter) Handler + func NewTypeHandler(callback Callback, filter Filter, eventType EventType) Handler + type KeyValue struct + Key string + Value int64 + type Location struct + Country string + G string + Latitude float64 + Longitude float64 + Text string + type Message struct + AnonSeed string + DeleteID string + Flag int64 + FromAnon bool + FromSelf bool + Group *Group + ID string + IsPrivate bool + ModerationID string + Private *Private + RawText string + ReceivedTime time.Time + Text string + Time time.Time + User *User + UserID string + UserIP string + func ParseAnnouncement(data string, group *Group) *Message + func ParseGroupMessage(data string, group *Group) *Message + func ParsePrivateMessage(data string, private *Private) *Message + func (m *Message) BanUser() error + func (m *Message) Channel() int64 + func (m *Message) Delete() error + func (m *Message) DeleteAll() error + func (m *Message) HasBackground() bool + func (m *Message) HasMedia() bool + func (m *Message) HasPremium() bool + func (m *Message) NameColor() string + func (m *Message) Reply(text string) (*Message, error) + func (m *Message) TextStyle() (textColor, textFont string, textSize int) + type MessageHandler struct + Callback Callback + Filter Filter + func (mh *MessageHandler) Check(event *Event) bool + func (mh *MessageHandler) Invoke(event *Event, context *Context) + type MiniProfile struct + Birth BirthDate + Body QueryEscaped + Gender string + Location Location + Premium PremiumDate + XMLName xml.Name + type ModAction struct + Extra string + ID int + IP string + Target string + Time time.Time + Type string + User string + func ParseModActions(data string) (modActions []*ModAction) + func (ma *ModAction) ExtraAsBool() (ret bool) + func (ma *ModAction) ExtraAsInt() (ret int64) + func (ma *ModAction) ExtraAsSliceInt() (ret []int64) + func (ma *ModAction) ExtraAsSliceInterface() (ret []interface{}) + func (ma *ModAction) ExtraBanWord() (ret BanWord) + func (ma *ModAction) ExtraDescription() (ret GroupInfo) + func (ma *ModAction) String() (actionDesc string) + type MyChatGroups struct + Groups [][2]string + RecentGroups [][2]string + UnreadMessages int + func (mg MyChatGroups) GetGroups() map[string]string + func (mg MyChatGroups) GetRecentGroups() map[string]string + type NotFilter struct + Base Filter + func (f *NotFilter) And(filter Filter) Filter + func (f *NotFilter) Check(event *Event) bool + func (f *NotFilter) Not() Filter + func (f *NotFilter) Or(filter Filter) Filter + func (f *NotFilter) Xor(filter Filter) Filter + type Number interface + type OrderedSyncMap struct + K []K + M map[K]V + func NewOrderedSyncMap() OrderedSyncMap[K, V] + func (sm *OrderedSyncMap[K, V]) Clear() + func (sm *OrderedSyncMap[K, V]) Del(key K) + func (sm *OrderedSyncMap[K, V]) Get(key K) (val V, ok bool) + func (sm *OrderedSyncMap[K, V]) GobDecode(data []byte) error + func (sm *OrderedSyncMap[K, V]) GobEncode() ([]byte, error) + func (sm *OrderedSyncMap[K, V]) Keys() []K + func (sm *OrderedSyncMap[K, V]) Len() int + func (sm *OrderedSyncMap[K, V]) Range(fun func(K, V) bool) + func (sm *OrderedSyncMap[K, V]) RangeReversed(fun func(K, V) bool) + func (sm *OrderedSyncMap[K, V]) Set(key K, val V) + func (sm *OrderedSyncMap[K, V]) SetFront(key K, val V) + func (sm *OrderedSyncMap[K, V]) TrimFront(length int) + type Participant struct + ID string + ParticipantID string + Time time.Time + User *User + type PeopleQuery struct + AgeFrom int + AgeTo int + Amount int + Gender string + Latitude string + Longtitude string + Offset int + Online bool + Radius int + Username string + func (pq *PeopleQuery) GetForm() (form url.Values) + func (pq *PeopleQuery) NextOffset() + type Persistence struct + BotData SyncMap[string, any] + ChatData SyncMap[string, *SyncMap[string, any]] + Filename string + Interval time.Duration + func (p *Persistence) Close() error + func (p *Persistence) DelChatData(key string) + func (p *Persistence) GetBotData() *SyncMap[string, any] + func (p *Persistence) GetChatData(key string) *SyncMap[string, any] + func (p *Persistence) Initialize() error + func (p *Persistence) Load() error + func (p *Persistence) Save() error + type PremiumDate time.Time + func (c *PremiumDate) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error + type Private struct + App *Application + Connected bool + IsIdle bool + LoginName string + LoginTime time.Time + Name string + NameColor string + SessionID string + TextColor string + TextFont string + TextSize int + TimeDiff time.Duration + WsUrl string + func (p *Private) AddFriend(username string) (status UserStatus, err error) + func (p *Private) Block(username string) (err error) + func (p *Private) Connect(ctx context.Context) (err error) + func (p *Private) ConnectUser(username string) (status UserStatus, err error) + func (p *Private) Disconnect() + func (p *Private) DisconnectUser(username string) (err error) + func (p *Private) GetBlocked() (users []*User, err error) + func (p *Private) GetContext() context.Context + func (p *Private) GetFriendList() (friendlist []UserStatus, err error) + func (p *Private) GetPresence(usernames []string) (statuslist []UserStatus, err error) + func (p *Private) GetSettings() (setting PrivateSetting, err error) + func (p *Private) ProfileRefresh() error + func (p *Private) PropagateEvent(frame string) + func (p *Private) Reconnect() (err error) + func (p *Private) RemoveFriend(username string) (err error) + func (p *Private) Send(args ...string) error + func (p *Private) SendMessage(username, text string) (err error) + func (p *Private) SetSettings(setting PrivateSetting) (err error) + func (p *Private) SyncSend(cb func(string) bool, text ...string) error + func (p *Private) SyncSendWithTimeout(callback func(string) bool, timeout time.Duration, args ...string) (err error) + func (p *Private) Track(username string) (status UserStatus, err error) + func (p *Private) Unblock(username string) (err error) + func (p *Private) WentActive() + func (p *Private) WentIdle() + type PrivateSetting struct + AllowAnon bool + DisableIdleTime bool + EmailOfflineMsg bool + type QueryEscaped string + func (c *QueryEscaped) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error + type RegexFilter struct + Pattern *regexp.Regexp + func (f *RegexFilter) And(filter Filter) Filter + func (f *RegexFilter) Check(event *Event) bool + func (f *RegexFilter) Not() Filter + func (f *RegexFilter) Or(filter Filter) Filter + func (f *RegexFilter) Xor(filter Filter) Filter + type SyncMap struct + M map[K]V + func NewSyncMap() SyncMap[K, V] + func (sm *SyncMap[K, V]) Clear() + func (sm *SyncMap[K, V]) Del(key K) + func (sm *SyncMap[K, V]) Get(key K) (val V, ok bool) + func (sm *SyncMap[K, V]) GobDecode(data []byte) error + func (sm *SyncMap[K, V]) GobEncode() ([]byte, error) + func (sm *SyncMap[K, V]) Keys() (keys []K) + func (sm *SyncMap[K, V]) Len() int + func (sm *SyncMap[K, V]) Range(fun func(K, V) bool) + func (sm *SyncMap[K, V]) Set(key K, val V) + type Transport struct + Headers map[string]string + Transport http.RoundTripper + func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) + type TypeHandler struct + Callback Callback + Filter Filter + Type EventType + func (th *TypeHandler) Check(event *Event) bool + func (th *TypeHandler) Invoke(event *Event, context *Context) + type Unblocked struct + IP string + ModerationID string + Target string + Time time.Time + Unblocker string + type User struct + IsAnon bool + IsSelf bool + Name string + type UserFilter struct + Users []string + func (f *UserFilter) Add(userName string) + func (f *UserFilter) And(filter Filter) Filter + func (f *UserFilter) Check(event *Event) bool + func (f *UserFilter) Not() Filter + func (f *UserFilter) Or(filter Filter) Filter + func (f *UserFilter) Remove(userName string) + func (f *UserFilter) Xor(filter Filter) Filter + type UserStatus struct + Idle time.Duration + Info string + Time time.Time + User *User + type WebSocket struct + Connected bool + Events chan string + OnError func(error) + func (w *WebSocket) Close() + func (w *WebSocket) Connect(url string) (err error) + func (w *WebSocket) Recv() (msg string, err error) + func (w *WebSocket) Send(msg string) (err error) + func (w *WebSocket) Sustain(ctx context.Context)