ext.go 764 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package tgbot
  2. import (
  3. "encoding/json"
  4. tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
  5. )
  6. func CreateChatInviteLink(botApi *tgbotapi.BotAPI, config tgbotapi.CreateChatInviteLinkConfig) (*tgbotapi.ChatInviteLink, error) {
  7. resp, err := botApi.Request(config)
  8. if err != nil {
  9. return nil, err
  10. }
  11. var message tgbotapi.ChatInviteLink
  12. err = json.Unmarshal(resp.Result, &message)
  13. if err != nil {
  14. return nil, err
  15. }
  16. return &message, nil
  17. }
  18. func ApproveChatJoinRequest(botApi *tgbotapi.BotAPI, config tgbotapi.ApproveChatJoinRequestConfig) error {
  19. resp, err := botApi.Request(config)
  20. if err != nil {
  21. return err
  22. }
  23. var message tgbotapi.Message
  24. err = json.Unmarshal(resp.Result, &message)
  25. if err != nil {
  26. return err
  27. }
  28. return nil
  29. }