members

package
v0.110.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package members defines interfaces for working with chat/channel members.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminRights

type AdminRights struct {
	// Indicates the role (rank) of the admin in the group: just an arbitrary string.
	//
	// If empty, will not be used.
	Rank string
	// If set, allows the admin to modify the description of the channel/supergroup.
	ChangeInfo bool
	// If set, allows the admin to post messages in the channel.
	PostMessages bool
	// If set, allows the admin to also edit messages from other admins in the channel.
	EditMessages bool
	// If set, allows the admin to also delete messages from other admins in the channel.
	DeleteMessages bool
	// If set, allows the admin to ban users from the channel/supergroup.
	BanUsers bool
	// If set, allows the admin to invite users in the channel/supergroup.
	InviteUsers bool
	// If set, allows the admin to pin messages in the channel/supergroup.
	PinMessages bool
	// If set, allows the admin to add other admins with the same (or more limited)
	// permissions in the channel/supergroup.
	AddAdmins bool
	// Whether this admin is anonymous.
	Anonymous bool
	// If set, allows the admin to change group call/livestream settings.
	ManageCall bool
	// Set this flag if none of the other flags are set, but you still want the user to be an
	// admin.
	Other bool
}

AdminRights represents admin right settings.

func (AdminRights) IntoChatAdminRights

func (b AdminRights) IntoChatAdminRights() (r tg.ChatAdminRights)

IntoChatAdminRights converts AdminRights into tg.ChatAdminRights.

type Callback

type Callback = func(p Member) error

Callback is type for member iterator callback.

type ChannelInfoUnavailableError

type ChannelInfoUnavailableError struct {
}

ChannelInfoUnavailableError reports that channel members info is not available.

func (*ChannelInfoUnavailableError) Error

Error implements error.

type ChannelMember

type ChannelMember struct {
	// contains filtered or unexported fields
}

ChannelMember is channel Member.

func (ChannelMember) InvitedBy

func (c ChannelMember) InvitedBy() (peers.User, bool)

InvitedBy returns user that invited this member.

func (ChannelMember) JoinDate

func (c ChannelMember) JoinDate() (time.Time, bool)

JoinDate returns member join date, if it is available.

func (ChannelMember) Kick

func (c ChannelMember) Kick(ctx context.Context, revokeHistory bool) error

Kick kicks this member.

If revokeHistory is set, will delete all messages from this member.

func (ChannelMember) Rank

func (c ChannelMember) Rank() (string, bool)

Rank returns admin "rank".

func (ChannelMember) Raw

Raw returns raw member object.

func (ChannelMember) Status

func (c ChannelMember) Status() Status

Status returns member Status.

func (ChannelMember) User

func (c ChannelMember) User() peers.User

User returns member User object.

type ChannelMembers

type ChannelMembers struct {
	// contains filtered or unexported fields
}

ChannelMembers is channel Members.

func Channel

func Channel(channel peers.Channel) *ChannelMembers

Channel returns recent channel members.

func (*ChannelMembers) Count

func (c *ChannelMembers) Count(ctx context.Context) (int, error)

Count returns total count of members.

func (*ChannelMembers) EditAdminRights

func (c *ChannelMembers) EditAdminRights(
	ctx context.Context,
	admin tg.InputUserClass,
	options AdminRights,
) error

EditAdminRights edits admin rights of given user in this channel.

func (*ChannelMembers) EditMemberRights

func (c *ChannelMembers) EditMemberRights(
	ctx context.Context,
	member tg.InputPeerClass,
	options MemberRights,
) error

EditMemberRights edits member rights in this channel.

func (*ChannelMembers) EditRights

func (c *ChannelMembers) EditRights(ctx context.Context, options MemberRights) error

EditRights edits rights of all members in this channel.

func (*ChannelMembers) ForEach

func (c *ChannelMembers) ForEach(ctx context.Context, cb Callback) error

ForEach calls cb for every member of channel.

May return ChannelInfoUnavailableError.

func (*ChannelMembers) Kick

func (c *ChannelMembers) Kick(ctx context.Context, member tg.InputUserClass, revokeHistory bool) error

Kick kicks user member.

Needed for parity with ChatMembers to define common interface.

If revokeHistory is set, will delete all messages from this member.

func (*ChannelMembers) KickMember

func (c *ChannelMembers) KickMember(ctx context.Context, member tg.InputPeerClass) error

KickMember kicks member.

Unlike Kick, KickMember can be used to kick chat member that uses send-as-channel mode.

func (*ChannelMembers) Peer

func (c *ChannelMembers) Peer() peers.Peer

Peer returns chat object.

type ChannelQuery

type ChannelQuery struct {
	Channel peers.Channel
}

ChannelQuery is builder for channel members querying.

func (ChannelQuery) Admins

func (q ChannelQuery) Admins() *ChannelMembers

Admins queries admins members.

func (ChannelQuery) Banned

func (q ChannelQuery) Banned(query string) *ChannelMembers

Banned queries banned members.

func (ChannelQuery) Bots

func (q ChannelQuery) Bots() *ChannelMembers

Bots queries bots members.

func (ChannelQuery) Contacts

func (q ChannelQuery) Contacts(query string) *ChannelMembers

Contacts queries members that are also contacts.

func (ChannelQuery) Custom

Custom creates query with custom filter.

func (ChannelQuery) Kicked

func (q ChannelQuery) Kicked(query string) *ChannelMembers

Kicked queries kicked members.

func (ChannelQuery) Recent

func (q ChannelQuery) Recent() *ChannelMembers

Recent queries recent members.

func (ChannelQuery) Search

func (q ChannelQuery) Search(query string) *ChannelMembers

Search queries members by given name.

type ChatInfoUnavailableError

type ChatInfoUnavailableError struct {
	Info *tg.ChatParticipantsForbidden
}

ChatInfoUnavailableError reports that chat members info is not available.

func (*ChatInfoUnavailableError) Error

func (c *ChatInfoUnavailableError) Error() string

Error implements error.

type ChatMember

type ChatMember struct {
	// contains filtered or unexported fields
}

ChatMember is chat Member.

func (ChatMember) InvitedBy

func (c ChatMember) InvitedBy() (peers.User, bool)

InvitedBy returns user that invited this member.

func (ChatMember) JoinDate

func (c ChatMember) JoinDate() (time.Time, bool)

JoinDate returns member join date, if it is available.

func (ChatMember) Kick

func (c ChatMember) Kick(ctx context.Context, revokeHistory bool) error

Kick kicks this member.

If revokeHistory is set, will delete all messages from this member.

func (ChatMember) Raw

Raw returns raw member object.

func (ChatMember) Status

func (c ChatMember) Status() Status

Status returns member Status.

func (ChatMember) User

func (c ChatMember) User() peers.User

User returns member User object.

type ChatMembers

type ChatMembers struct {
	// contains filtered or unexported fields
}

ChatMembers is chat Members.

func Chat

func Chat(chat peers.Chat) *ChatMembers

Chat returns recent chat members.

func (*ChatMembers) Count

func (c *ChatMembers) Count(ctx context.Context) (int, error)

Count returns total count of members.

func (*ChatMembers) EditAdmin

func (c *ChatMembers) EditAdmin(ctx context.Context, user tg.InputUserClass, isAdmin bool) error

EditAdmin edits admin rights for given user.

func (*ChatMembers) EditRights

func (c *ChatMembers) EditRights(ctx context.Context, options MemberRights) error

EditRights edits rights of all members in this chat.

func (*ChatMembers) ForEach

func (c *ChatMembers) ForEach(ctx context.Context, cb Callback) error

ForEach calls cb for every member of chat.

May return ChatInfoUnavailableError.

func (*ChatMembers) Kick

func (c *ChatMembers) Kick(ctx context.Context, member tg.InputUserClass, revokeHistory bool) error

Kick kicks user member.

If revokeHistory is set, will delete all messages from this member.

func (*ChatMembers) Peer

func (c *ChatMembers) Peer() peers.Peer

Peer returns chat object.

type Member

type Member interface {
	// Status returns member Status.
	Status() Status
	// JoinDate returns member join date, if it is available.
	JoinDate() (time.Time, bool)
	// InvitedBy returns user that invited this member.
	InvitedBy() (peers.User, bool)
	// User returns member User object.
	User() peers.User
	// Kick kicks this member.
	//
	// If revokeHistory is set, will delete all messages from this member.
	Kick(ctx context.Context, revokeHistory bool) error
}

Member represents chat/channel member.

type MemberRights

type MemberRights struct {
	// If set, does not allow a user to view messages in a supergroup/channel/chat.
	//
	// In fact, user will be kicked.
	DenyViewMessages bool
	// If set, does not allow a user to send messages in a supergroup/chat.
	DenySendMessages bool
	// If set, does not allow a user to send any media in a supergroup/chat.
	DenySendMedia bool
	// If set, does not allow a user to send stickers in a supergroup/chat.
	DenySendStickers bool
	// If set, does not allow a user to send gifs in a supergroup/chat.
	DenySendGifs bool
	// If set, does not allow a user to send games in a supergroup/chat.
	DenySendGames bool
	// If set, does not allow a user to use inline bots in a supergroup/chat.
	DenySendInline bool
	// If set, does not allow a user to embed links in the messages of a supergroup/chat.
	DenyEmbedLinks bool
	// If set, does not allow a user to send polls in a supergroup/chat.
	DenySendPolls bool
	// If set, does not allow any user to change the description of a supergroup/chat.
	DenyChangeInfo bool
	// If set, does not allow any user to invite users in a supergroup/chat.
	DenyInviteUsers bool
	// If set, does not allow any user to pin messages in a supergroup/chat.
	DenyPinMessages bool
	// Validity of said permissions (it is considered forever any value less than 30 seconds or more than 366 days).
	//
	// If value is zero, value will not be used.
	UntilDate time.Time
}

MemberRights represents member right settings.

func (*MemberRights) ApplyFor

func (b *MemberRights) ApplyFor(d time.Duration)

ApplyFor sets duration of validity of set rights.

func (MemberRights) IntoChatBannedRights

func (b MemberRights) IntoChatBannedRights() (r tg.ChatBannedRights)

IntoChatBannedRights converts MemberRights into tg.ChatBannedRights.

type Members

type Members interface {
	// ForEach calls cb for every member of chat/channel.
	ForEach(ctx context.Context, cb Callback) error
	// Count returns total count of members.
	Count(ctx context.Context) (int, error)
	// Peer returns chat object.
	Peer() peers.Peer
	// Kick kicks user member.
	//
	// If revokeHistory is set, will delete all messages from this member.
	Kick(ctx context.Context, member tg.InputUserClass, revokeHistory bool) error
	// EditRights edits rights of all members in this chat/channel.
	EditRights(ctx context.Context, options MemberRights) error
}

Members represents chat/channel members.

type Status

type Status int

Status defines participant status.

const (
	// Plain is status for plain participant.
	Plain Status = iota
	// Creator is status for chat/channel creator.
	Creator
	// Admin is status for chat/channel admin.
	Admin
	// Banned is status for banned user.
	Banned
	// Left is status for user that left chat/channel.
	Left
)

func (Status) String

func (i Status) String() string

Jump to

Keyboard shortcuts

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