telegram

package
v0.0.0-...-04ff805 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

func NewBot

func NewBot(key, proxy string, logger glog.Interface) (*Bot, error)

func (*Bot) Answer

func (b *Bot) Answer(m Msg, text string) (Msg, error)

func (*Bot) BanGroupMember

func (b *Bot) BanGroupMember(chatId int64, userId int, blockTime time.Duration) error

加入黑名单并且禁言,但是仍然留在群里可以看不可以操作

func (*Bot) BlockGroupMember

func (b *Bot) BlockGroupMember(chatId int64, userId int) error

加入黑名单并且永久地踢出去(连看消息的权限都没有) 经测试发现:是否填写SuperGroupUsername或者ChannelUsername根本没有关系,ChatId却是必须的,没有ChatId只有群组名称,函数是没有效果的,也不报错 当然,也可能是测试不严谨的误判

func (*Bot) GetAdminsByMsg

func (b *Bot) GetAdminsByMsg(m Msg) ([]User, error)

耗时较长 从消息查询消息出处的所有管理员

func (*Bot) GetGroupMembers

func (b *Bot) GetGroupMembers() ([]User, error)

获取群组全部成员名单

func (*Bot) GetMe

func (b *Bot) GetMe() (User, error)

func (*Bot) GetNewMsgChan

func (b *Bot) GetNewMsgChan() (MsgChan, error)

func (*Bot) IsMsgFromAdmin

func (b *Bot) IsMsgFromAdmin(m Msg) (bool, error)

消息是否是来自管理员

func (*Bot) RemoveMsg

func (b *Bot) RemoveMsg(m Msg) error

func (*Bot) RemoveMsgById

func (b *Bot) RemoveMsgById(chatId int64, msgId int) error

func (*Bot) Reply

func (b *Bot) Reply(m Msg, text string) (Msg, error)

func (*Bot) SendImageToPublicChannel

func (b *Bot) SendImageToPublicChannel(channelUserName, imageBuffer []byte) (Msg, error)

func (*Bot) SendTextToPrivateChannel

func (b *Bot) SendTextToPrivateChannel(chatIdOfChannel int64, text string) (Msg, error)

Every private channel has a unique and solid chat id.

func (*Bot) SendTextToPublicChannel

func (b *Bot) SendTextToPublicChannel(channelUserName, text string) (Msg, error)

只有加入了群,才能发送消息到该群 channelUserName: for example, https://t.me/rich, the channel username is 'rich'.

func (*Bot) UnBanGroupMember

func (b *Bot) UnBanGroupMember(chatId int64, channelUsername, superGroupUsername string, userId int, blockTime time.Duration) error

func (*Bot) UserHasAvatar

func (b *Bot) UserHasAvatar(userId int) (bool, error)

Does user have avatar or not

type ChatType

type ChatType int
const (
	ChatTypeSuperGroup ChatType = iota + 0
	ChatTypeChannel
	ChatTypePrivate // 一对一私聊
	ChatTypeUnknown
)

type Group

type Group tgbotapi.Chat

type Msg

type Msg tgbotapi.Message

func (*Msg) ChatType

func (m *Msg) ChatType() ChatType

func (*Msg) FromGroup

func (m *Msg) FromGroup() (isMsgFromGroup bool, group Group)

消息来自哪个群组

func (*Msg) FromUser

func (m *Msg) FromUser() User

func (*Msg) MsgType

func (m *Msg) MsgType() MsgType

func (*Msg) ToJson

func (m *Msg) ToJson() (string, error)

type MsgChan

type MsgChan <-chan Msg

type MsgType

type MsgType int
const (
	MsgTyepJoin MsgType = iota + 0
	MsgTypeInvite
	MsgTypeText
	MsgTypeImage
	MsgTypeAudio
	MsgTypeVideo
	MsgTypeFile
	MsgTypeLocation
	MsgTypeUnknown
)

type User

type User tgbotapi.User

Jump to

Keyboard shortcuts

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