telegram.go 726 B

1234567891011121314151617181920212223242526272829303132
  1. package third
  2. import (
  3. "fmt"
  4. jsoniter "github.com/json-iterator/go"
  5. mhayaHttp "github.com/mhaya/extend/http"
  6. "github.com/mhaya/game/game_cluster/internal/data"
  7. )
  8. type GetIfChannelResp struct {
  9. Result struct {
  10. Status string `json:"status"`
  11. } `json:"result"`
  12. }
  13. func GetIfChannel(userID string) int32 {
  14. ret := data.SdkConfig.Get(3)
  15. params := map[string]string{}
  16. rs, _, err := mhayaHttp.GET(fmt.Sprintf("%v%v/getChatMember?chat_id=%v&user_id=%v", ret.Params.AppUrl, ret.Params.BotToken, ret.Params.ChatIDName, userID), params)
  17. if err != nil {
  18. return 0
  19. }
  20. var resp GetIfChannelResp
  21. err = jsoniter.Unmarshal(rs, &resp)
  22. if err != nil {
  23. return 0
  24. }
  25. if resp.Result.Status == "member" {
  26. return 1
  27. }
  28. return 0
  29. }