Merge pull request #377 from omar-polo/v2

implements voice chat service messages
pull/425/head
Ian P Badtrousers 4 years ago committed by Demian
parent 1b57dbc404
commit 8261689cda

@ -22,6 +22,7 @@ type Rights struct {
CanSendPolls bool `json:"can_send_polls"`
CanSendOther bool `json:"can_send_other_messages"`
CanAddPreviews bool `json:"can_add_web_page_previews"`
CanManageVoiceChats bool `json:"can_manage_voice_chats"`
}
// NoRights is the default Rights{}.
@ -49,6 +50,7 @@ func NoRestrictions() Rights {
CanSendPolls: true,
CanSendOther: true,
CanAddPreviews: true,
CanManageVoiceChats: false,
}
}
@ -69,6 +71,7 @@ func AdminRights() Rights {
CanSendPolls: true,
CanSendOther: true,
CanAddPreviews: true,
CanManageVoiceChats: true,
}
}

@ -349,6 +349,21 @@ func (b *Bot) ProcessUpdate(upd Update) {
b.handle(OnMigration, c)
return
}
if m.VoiceChatStarted != nil {
b.handle(OnVoiceChatStarted, c)
return
}
if m.VoiceChatEnded != nil {
b.handle(OnVoiceChatEnded, c)
return
}
if m.VoiceChatParticipants != nil {
b.handle(OnVoiceChatParticipants, c)
return
}
}
if upd.EditedMessage != nil {

@ -49,7 +49,7 @@ func TestNewBot(t *testing.T) {
_, err = NewBot(pref)
assert.Error(t, err)
b, err := NewBot(Settings{offline: true})
b, err := NewBot(Settings{Offline: true})
if err != nil {
t.Fatal(err)
}
@ -66,7 +66,7 @@ func TestNewBot(t *testing.T) {
pref.Poller = &LongPoller{Timeout: time.Second}
pref.Updates = 50
pref.ParseMode = ModeHTML
pref.offline = true
pref.Offline = true
b, err = NewBot(pref)
require.NoError(t, err)
@ -147,7 +147,7 @@ func TestBotStart(t *testing.T) {
}
func TestBotProcessUpdate(t *testing.T) {
b, err := NewBot(Settings{Synchronous: true, offline: true})
b, err := NewBot(Settings{Synchronous: true, Offline: true})
if err != nil {
t.Fatal(err)
}
@ -340,7 +340,7 @@ func TestBotProcessUpdate(t *testing.T) {
}
func TestBotOnError(t *testing.T) {
b, err := NewBot(Settings{Synchronous: true, offline: true})
b, err := NewBot(Settings{Synchronous: true, Offline: true})
if err != nil {
t.Fatal(err)
}

@ -217,6 +217,15 @@ type Message struct {
// Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
// For a service message, a voice chat started in the chat.
VoiceChatStarted *VoiceChatStarted `json:"voice_chat_started,omitempty"`
// For a service message, a voice chat ended in the chat.
VoiceChatEnded *VoiceChatEnded `json:"voice_chat_ended,omitempty"`
// For a service message, some users were invited in the voice chat.
VoiceChatParticipants *VoiceChatParticipants `json:"voice_chat_participants_invited,omitempty"`
}
// MessageEntity object represents "special" parts of text messages,

@ -121,6 +121,21 @@ const (
//
// Handler: func(*PollAnswer)
OnPollAnswer = "\apoll_answer"
// Will fire on VoiceChatStarted
//
// Handler: func(*Message)
OnVoiceChatStarted = "\avoice_chat_started"
// Will fire on VoiceChatEnded
//
// Handler: func(*Message)
OnVoiceChatEnded = "\avoice_chat_ended"
// Will fire on VoiceChatParticipants
//
// Handler: func(*Message)
OnVoiceChatParticipants = "\avoice_chat_participants_invited"
)
// ChatAction is a client-side status indicating bot activity.

@ -0,0 +1,17 @@
package telebot
// VoiceChatStarted represents a service message about a voice chat
// started in the chat.
type VoiceChatStarted struct{}
// VoiceChatEnded represents a service message about a voice chat
// ended in the chat.
type VoiceChatEnded struct {
Duration int `json:"duration"`
}
// VoiceChatParticipants represents a service message about new
// members invited to a voice chat
type VoiceChatParticipants struct {
Users []User `json:"users"`
}
Loading…
Cancel
Save