code: func (b *Bmattermost) handleDownloadAvatar(userid string, channel string) {
  	rmsg := config.Message{
  		Username: "system",
  		Text:     "avatar",
  		Channel:  channel,
  		Account:  b.Account,
  		UserID:   userid,
  		Event:    config.EventAvatarDownload,
  		Extra:    make(map[string][]interface{}),
  	}
  	if _, ok := b.avatarMap[userid]; !ok {
  		data, resp := b.mc.Client.GetProfileImage(userid, "")
  		if resp.Error != nil {
  			b.Log.Errorf("ProfileImage download failed for %#v %s", userid, resp.Error)
  			return
  		}
  		err := helper.HandleDownloadSize(b.Log, &rmsg, userid+".png", int64(len(data)), b.General)
  		if err != nil {
  			b.Log.Error(err)
  			return
  		}
  		helper.HandleDownloadData(b.Log, &rmsg, userid+".png", 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