code: func (b *Btelegram) handleDownloadAvatar(userid int, channel string) {
  	rmsg := config.Message{Username: "system",
  		Text:    "avatar",
  		Channel: channel,
  		Account: b.Account,
  		UserID:  strconv.Itoa(userid),
  		Event:   config.EventAvatarDownload,
  		Extra:   make(map[string][]interface{})}
  
  	if _, ok := b.avatarMap[strconv.Itoa(userid)]; !ok {
  		photos, err := b.c.GetUserProfilePhotos(tgbotapi.UserProfilePhotosConfig{UserID: userid, Limit: 1})
  		if err != nil {
  			b.Log.Errorf("Userprofile download failed for %#v %s", userid, err)
  		}
  
  		if len(photos.Photos) > 0 {
  			photo := photos.Photos[0][0]
  			url := b.getFileDirectURL(photo.FileID)
  			name := strconv.Itoa(userid) + ".png"
  			b.Log.Debugf("trying to download %#v fileid %#v with size %#v", name, photo.FileID, photo.FileSize)
  
  			err := helper.HandleDownloadSize(b.Log, &rmsg, name, int64(photo.FileSize), b.General)
  			if err != nil {
  				b.Log.Error(err)
  				return
  			}
  			data, err := helper.DownloadFile(url)
  			if err != nil {
  				b.Log.Errorf("download %s failed %#v", url, err)
  				return
  			}
  			helper.HandleDownloadData(b.Log, &rmsg, name, rmsg.Text, "", data, b.General)
  			b.Remote <- rmsg
  		}
  	}
  }
docs: // handleDownloadAvatar downloads the avatar of userid from channel
  // sends a EVENT_AVATAR_DOWNLOAD message to the gateway if successful.
  // logs an error message if it fails