mirror of https://github.com/tucnak/telebot
api: features 7.0, 7.1 (#658)
* api: feature 7.0 init * message: remove blockquote * api: partrly implement replies 2.0 * api: update comments * message: add giveaway fields * message,chat: other changes init * boost: implement boost updates * reactions: refactor * api: implement multiple users request section * api: provide preview customization * api: implement 7.1 features * message: fix story issue * admin,context: refactor * bot_test: type refactor * api: partly fix review comments * api: small tidy up * react: reactions init * telebot: added boost_updated,boost_removed constants * message: fix InaccessibleMessage message struct parse * message,reac: naming refactor * context: add boost to the context of current eventsv3.3
parent
b67df6444e
commit
6fdf666a11
@ -0,0 +1,111 @@
|
||||
package telebot
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Boost contains information about a chat boost.
|
||||
type Boost struct {
|
||||
// Unique identifier of the boost.
|
||||
ID string `json:"boost_id"`
|
||||
|
||||
// Point in time (Unix timestamp) when the chat was boosted.
|
||||
AddUnixtime int64 `json:"add_date"`
|
||||
|
||||
// Point in time (Unix timestamp) when the boost will automatically expire,
|
||||
// unless the booster's Telegram Premium subscription is prolonged.
|
||||
ExpirationUnixtime int64 `json:"expiration_date"`
|
||||
|
||||
// Source of the added boost.
|
||||
Source *BoostSource `json:"source"`
|
||||
}
|
||||
|
||||
// AddDate returns the moment of time when the chat has been boosted in local time.
|
||||
func (c *Boost) AddDate() time.Time {
|
||||
return time.Unix(c.AddUnixtime, 0)
|
||||
}
|
||||
|
||||
// ExpirationDate returns the moment of time when the boost of the channel
|
||||
// will expire in local time.
|
||||
func (c *Boost) ExpirationDate() time.Time {
|
||||
return time.Unix(c.ExpirationUnixtime, 0)
|
||||
}
|
||||
|
||||
// BoostSourceType describes a type of boost.
|
||||
type BoostSourceType = string
|
||||
|
||||
const (
|
||||
BoostPremium = "premium"
|
||||
BoostGiftCode = "gift_code"
|
||||
BoostGiveaway = "giveaway"
|
||||
)
|
||||
|
||||
// BoostSource describes the source of a chat boost.
|
||||
type BoostSource struct {
|
||||
// Source of the boost, always (“premium”, “gift_code”, “giveaway”).
|
||||
Source BoostSourceType `json:"source"`
|
||||
|
||||
// User that boosted the chat.
|
||||
Booster *User `json:"user"`
|
||||
|
||||
// Identifier of a message in the chat with the giveaway; the message
|
||||
// could have been deleted already. May be 0 if the message isn't sent yet.
|
||||
GiveawayMessageID int `json:"giveaway_message_id,omitempty"`
|
||||
|
||||
// (Optional) True, if the giveaway was completed, but there was
|
||||
// no user to win the prize.
|
||||
Unclaimed bool `json:"is_unclaimed,omitempty"`
|
||||
}
|
||||
|
||||
// BoostAdded represents a service message about a user boosting a chat.
|
||||
type BoostAdded struct {
|
||||
// Number of boosts added by the user.
|
||||
Count int `json:"boost_count"`
|
||||
}
|
||||
|
||||
// BoostUpdated represents a boost added to a chat or changed.
|
||||
type BoostUpdated struct {
|
||||
// Chat which was boosted.
|
||||
Chat *Chat `json:"chat"`
|
||||
|
||||
// Information about the chat boost.
|
||||
Boost *Boost `json:"boost"`
|
||||
}
|
||||
|
||||
// BoostRemoved represents a boost removed from a chat.
|
||||
type BoostRemoved struct {
|
||||
// Chat which was boosted.
|
||||
Chat *Chat `json:"chat"`
|
||||
|
||||
// Unique identifier of the boost.
|
||||
BoostID string `json:"boost_id"`
|
||||
|
||||
// Point in time (Unix timestamp) when the boost was removed.
|
||||
RemoveUnixtime int64 `json:"remove_date"`
|
||||
|
||||
// Source of the removed boost.
|
||||
Source *BoostSource `json:"source"`
|
||||
}
|
||||
|
||||
// UserBoosts gets the list of boosts added to a chat by a user.
|
||||
// Requires administrator rights in the chat.
|
||||
func (b *Bot) UserBoosts(chat, user Recipient) ([]Boost, error) {
|
||||
params := map[string]string{
|
||||
"chat_id": chat.Recipient(),
|
||||
"user_id": user.Recipient(),
|
||||
}
|
||||
|
||||
data, err := b.Raw("getUserChatBoosts", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var resp struct {
|
||||
Result []Boost `json:"boosts"`
|
||||
}
|
||||
if err := json.Unmarshal(data, &resp); err != nil {
|
||||
return nil, wrapError(err)
|
||||
}
|
||||
return resp.Result, nil
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package telebot
|
||||
|
||||
import "time"
|
||||
|
||||
// Giveaway represents a message about a scheduled giveaway.
|
||||
type Giveaway struct {
|
||||
// The list of chats which the user must join to participate in the giveaway.
|
||||
Chats []Chat `json:"chats"`
|
||||
|
||||
// Point in time (Unix timestamp) when winners of the giveaway will be selected.
|
||||
SelectionUnixtime int64 `json:"winners_selection_date"`
|
||||
|
||||
// The number of users which are supposed to be selected as winners of the giveaway.
|
||||
WinnerCount int `json:"winner_count"`
|
||||
|
||||
// (Optional) True, if only users who join the chats after the giveaway
|
||||
// started should be eligible to win.
|
||||
OnlyNewMembers bool `json:"only_new_members"`
|
||||
|
||||
// (Optional) True, if the list of giveaway winners will be visible to everyone.
|
||||
HasPublicWinners bool `json:"has_public_winners"`
|
||||
|
||||
// (Optional) Description of additional giveaway prize.
|
||||
PrizeDescription string `json:"prize_description"`
|
||||
|
||||
// (Optional) A list of two-letter ISO 3166-1 alpha-2 country codes indicating
|
||||
// the countries from which eligible users for the giveaway must come.
|
||||
// If empty, then all users can participate in the giveaway. Users with a phone number
|
||||
// that was bought on Fragment can always participate in giveaways.
|
||||
CountryCodes []string `json:"country_codes"`
|
||||
|
||||
// (Optional) The number of months the Telegram Premium subscription won from
|
||||
// the giveaway will be active for.
|
||||
PremiumMonthCount int `json:"premium_subscription_month_count"`
|
||||
}
|
||||
|
||||
// SelectionDate returns the moment of when winners of the giveaway were selected in local time.
|
||||
func (g *Giveaway) SelectionDate() time.Time {
|
||||
return time.Unix(g.SelectionUnixtime, 0)
|
||||
}
|
||||
|
||||
// GiveawayWinners object represents a message about the completion of a
|
||||
// giveaway with public winners.
|
||||
type GiveawayWinners struct {
|
||||
// The chat that created the giveaway.
|
||||
Chat *Chat `json:"chat"`
|
||||
|
||||
// Identifier of the message with the giveaway in the chat.
|
||||
MessageID int `json:"message_id"`
|
||||
|
||||
// Point in time (Unix timestamp) when winners of the giveaway were selected.
|
||||
SelectionUnixtime int64 `json:"winners_selection_date"`
|
||||
|
||||
// The number of users which are supposed to be selected as winners of the giveaway.
|
||||
WinnerCount int `json:"winner_count"`
|
||||
|
||||
// List of up to 100 winners of the giveaway.
|
||||
Winners []User `json:"winners"`
|
||||
|
||||
// (Optional) The number of other chats the user had to join in order
|
||||
// to be eligible for the giveaway.
|
||||
AdditionalChats int `json:"additional_chat_count"`
|
||||
|
||||
// (Optional) The number of months the Telegram Premium subscription won from
|
||||
// the giveaway will be active for.
|
||||
PremiumMonthCount int `json:"premium_subscription_month_count"`
|
||||
|
||||
// (Optional) Number of undistributed prizes.
|
||||
UnclaimedPrizes int `json:"unclaimed_prize_count"`
|
||||
|
||||
// (Optional) True, if only users who had joined the chats after the giveaway started
|
||||
// were eligible to win.
|
||||
OnlyNewMembers bool `json:"only_new_members"`
|
||||
|
||||
// (Optional) True, if the giveaway was canceled because the payment for it was refunded.
|
||||
Refunded bool `json:"was_refunded"`
|
||||
|
||||
// (Optional) Description of additional giveaway prize.
|
||||
PrizeDescription string `json:"prize_description"`
|
||||
}
|
||||
|
||||
// SelectionDate returns the moment of when winners of the giveaway
|
||||
// were selected in local time.
|
||||
func (g *GiveawayWinners) SelectionDate() time.Time {
|
||||
return time.Unix(g.SelectionUnixtime, 0)
|
||||
}
|
||||
|
||||
// GiveawayCreated represents a service message about the creation of a scheduled giveaway.
|
||||
// Currently holds no information.
|
||||
type GiveawayCreated struct{}
|
||||
|
||||
// GiveawayCompleted represents a service message about the completion of a
|
||||
// giveaway without public winners.
|
||||
type GiveawayCompleted struct {
|
||||
// Number of winners in the giveaway.
|
||||
WinnerCount int `json:"winner_count"`
|
||||
|
||||
// (Optional) Number of undistributed prizes.
|
||||
UnclaimedPrizes int `json:"unclaimed_prize_count"`
|
||||
|
||||
// (Optional) Message with the giveaway that was completed, if it wasn't deleted.
|
||||
Message *Message `json:"giveaway_message"`
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package react
|
||||
|
||||
// EmojiType defines emoji types.
|
||||
type EmojiType = string
|
||||
|
||||
// Currently available emojis.
|
||||
var (
|
||||
ThumbUp = Reaction{Emoji: "👍"}
|
||||
ThumbDown = Reaction{Emoji: "👎"}
|
||||
Heart = Reaction{Emoji: "❤"}
|
||||
Fire = Reaction{Emoji: "🔥"}
|
||||
HeartEyes = Reaction{Emoji: "😍"}
|
||||
ClappingHands = Reaction{Emoji: "👏"}
|
||||
GrinningFace = Reaction{Emoji: "😁"}
|
||||
ThinkingFace = Reaction{Emoji: "🤔"}
|
||||
ExplodingHead = Reaction{Emoji: "🤯"}
|
||||
ScreamingFace = Reaction{Emoji: "😱"}
|
||||
SwearingFace = Reaction{Emoji: "🤬"}
|
||||
CryingFace = Reaction{Emoji: "😢"}
|
||||
PartyPopper = Reaction{Emoji: "🎉"}
|
||||
StarStruck = Reaction{Emoji: "🤩"}
|
||||
VomitingFace = Reaction{Emoji: "🤮"}
|
||||
PileOfPoo = Reaction{Emoji: "💩"}
|
||||
PrayingHands = Reaction{Emoji: "🙏"}
|
||||
OkHand = Reaction{Emoji: "👌"}
|
||||
DoveOfPeace = Reaction{Emoji: "🕊"}
|
||||
ClownFace = Reaction{Emoji: "🤡"}
|
||||
YawningFace = Reaction{Emoji: "🥱"}
|
||||
WoozyFace = Reaction{Emoji: "🥴"}
|
||||
Whale = Reaction{Emoji: "🐳"}
|
||||
HeartOnFire = Reaction{Emoji: "❤🔥"}
|
||||
MoonFace = Reaction{Emoji: "🌚"}
|
||||
HotDog = Reaction{Emoji: "🌭"}
|
||||
HundredPoints = Reaction{Emoji: "💯"}
|
||||
RollingOnTheFloorLaughing = Reaction{Emoji: "🤣"}
|
||||
Lightning = Reaction{Emoji: "⚡"}
|
||||
Banana = Reaction{Emoji: "🍌"}
|
||||
Trophy = Reaction{Emoji: "🏆"}
|
||||
BrokenHeart = Reaction{Emoji: "💔"}
|
||||
FaceWithRaisedEyebrow = Reaction{Emoji: "🤨"}
|
||||
NeutralFace = Reaction{Emoji: "😐"}
|
||||
Strawberry = Reaction{Emoji: "🍓"}
|
||||
Champagne = Reaction{Emoji: "🍾"}
|
||||
KissMark = Reaction{Emoji: "💋"}
|
||||
MiddleFinger = Reaction{Emoji: "🖕"}
|
||||
EvilFace = Reaction{Emoji: "😈"}
|
||||
SleepingFace = Reaction{Emoji: "😴"}
|
||||
LoudlyCryingFace = Reaction{Emoji: "😭"}
|
||||
NerdFace = Reaction{Emoji: "🤓"}
|
||||
Ghost = Reaction{Emoji: "👻"}
|
||||
Engineer = Reaction{Emoji: "👨💻"}
|
||||
Eyes = Reaction{Emoji: "👀"}
|
||||
JackOLantern = Reaction{Emoji: "🎃"}
|
||||
NoMonkey = Reaction{Emoji: "🙈"}
|
||||
SmilingFaceWithHalo = Reaction{Emoji: "😇"}
|
||||
FearfulFace = Reaction{Emoji: "😨"}
|
||||
Handshake = Reaction{Emoji: "🤝"}
|
||||
WritingHand = Reaction{Emoji: "✍"}
|
||||
HuggingFace = Reaction{Emoji: "🤗"}
|
||||
Brain = Reaction{Emoji: "🫡"}
|
||||
SantaClaus = Reaction{Emoji: "🎅"}
|
||||
ChristmasTree = Reaction{Emoji: "🎄"}
|
||||
Snowman = Reaction{Emoji: "☃"}
|
||||
NailPolish = Reaction{Emoji: "💅"}
|
||||
ZanyFace = Reaction{Emoji: "🤪"}
|
||||
Moai = Reaction{Emoji: "🗿"}
|
||||
Cool = Reaction{Emoji: "🆒"}
|
||||
HeartWithArrow = Reaction{Emoji: "💘"}
|
||||
HearMonkey = Reaction{Emoji: "🙉"}
|
||||
Unicorn = Reaction{Emoji: "🦄"}
|
||||
FaceBlowingKiss = Reaction{Emoji: "😘"}
|
||||
Pill = Reaction{Emoji: "💊"}
|
||||
SpeaklessMonkey = Reaction{Emoji: "🙊"}
|
||||
Sunglasses = Reaction{Emoji: "😎"}
|
||||
AlienMonster = Reaction{Emoji: "👾"}
|
||||
ManShrugging = Reaction{Emoji: "🤷♂️"}
|
||||
PersonShrugging = Reaction{Emoji: "🤷"}
|
||||
WomanShrugging = Reaction{Emoji: "🤷♀️"}
|
||||
PoutingFace = Reaction{Emoji: "😡"}
|
||||
)
|
||||
|
||||
// Reaction describes the type of reaction.
|
||||
// Describes an instance of ReactionTypeCustomEmoji and ReactionTypeEmoji.
|
||||
type Reaction struct {
|
||||
// Type of the reaction, always “emoji”
|
||||
Type string `json:"type"`
|
||||
|
||||
// Reaction emoji.
|
||||
Emoji EmojiType `json:"emoji,omitempty"`
|
||||
|
||||
// Custom emoji identifier.
|
||||
CustomEmoji string `json:"custom_emoji_id,omitempty"`
|
||||
}
|
||||
|
||||
// Count represents a reaction added to a message along
|
||||
// with the number of times it was added.
|
||||
type Count struct {
|
||||
// Type of the reaction.
|
||||
Type Reaction `json:"type"`
|
||||
|
||||
// Number of times the reaction was added.
|
||||
Count int `json:"total_count"`
|
||||
}
|
||||
|
||||
// Options represents an object of reaction options.
|
||||
type Options struct {
|
||||
// List of reaction types to set on the message.
|
||||
Reactions []Reaction `json:"reaction"`
|
||||
|
||||
// Pass True to set the reaction with a big animation.
|
||||
Big bool `json:"is_big"`
|
||||
}
|
Loading…
Reference in New Issue