// Emojis creates an EmojisService with a base url
//
// https://developer.github.com/v3/emojis/
480140
func (c *Client) Emojis(url *url.URL) (emojis *EmojisService) {
	emojis = &EmojisService{client: c, URL: url}
	return
}
1245093
func (s *State) EmojisAdd(guildID string, emojis []*Emoji) error {
	for _, e := range emojis {
		if err := s.EmojiAdd(guildID, e); err != nil {
			return err
		}
	}
	return nil
}
438363
func baseURI(req *http.Request) string {
	scheme := strings.ToLower(req.URL.Scheme)
	host := strings.ToLower(req.URL.Host)
	if hostPort := strings.Split(host, ":"); len(hostPort) == 2 && (hostPort[1] == "80" || hostPort[1] == "443") {
		host = hostPort[0]
	}
	// TODO: use req.URL.EscapedPath() once Go 1.5 is more generally adopted
	// For now, hacky workaround accomplishes the same internal escaping mode
	// escape(u.Path, encodePath) for proper compliance with the OAuth1 spec.
	path := req.URL.Path
	if path != "" {
		path = strings.Split(req.URL.RequestURI(), "?")[0]
	}
	return fmt.Sprintf("%v://%v%v", scheme, host, path)
}
769351
func (service *BaseService) AddFunctions(names []string, functions []interface{}, option ...Options) Service {
	service.methodManager.AddFunctions(names, functions, option...)
	return service
}
455900
func (c *Client) ListEmojis(ctx context.Context) (map[string]string, *Response, error) {
	req, err := c.NewRequest("GET", "emojis", nil)
	if err != nil {
		return nil, nil, err
	}

	var emoji map[string]string
	resp, err := c.Do(ctx, req, &emoji)
	if err != nil {
		return nil, resp, err
	}

	return emoji, resp, nil
}
396931
func (ns *Namespace) Emojify(s interface{}) (template.HTML, error) {
	ss, err := cast.ToStringE(s)
	if err != nil {
		return "", err
	}

	return template.HTML(helpers.Emojify([]byte(ss))), nil
}
757466
func (m MiddlewareFunc) SchemeMatches(tests ...regexp.Regexp) MiddlewareFunc {
	return func(h HandlerFunc) HandlerFunc {
		return func(c *Context) error {
			for _, test := range tests {
				if test.MatchString(c.Request().URL().Scheme) {
					return m(h)(c)
				}
			}
			return h(c)
		}
	}
}
719507
func (f AnnotationsHandlerFunc) ServeAnnotations(ctx context.Context, res AnnotationsResponse, req *AnnotationsRequest) error {
	return f(ctx, res, req)
}
610648
func generateHashes(url string) (map[hashPrefix]string, error) {
	patterns, err := generatePatterns(url)
	if err != nil {
		return nil, err
	}

	hashes := make(map[hashPrefix]string)
	for _, p := range patterns {
		hashes[hashFromPattern(p)] = p
	}
	return hashes, nil
}
1072508
func URLFilters(filters ...*regexp.Regexp) func(*Collector) {
	return func(c *Collector) {
		c.URLFilters = filters
	}
}
931626
func addParams(url_ string, params url.Values) string {
	if len(params) == 0 {
		return url_
	}

	if !strings.Contains(url_, "?") {
		url_ += "?"
	}

	if strings.HasSuffix(url_, "?") || strings.HasSuffix(url_, "&") {
		url_ += params.Encode()
	} else {
		url_ += "&" + params.Encode()
	}

	return url_
}
139829
func (api *Client) GetEmojiContext(ctx context.Context) (map[string]string, error) {
	values := url.Values{
		"token": {api.token},
	}
	response := &emojiResponseFull{}

	err := api.postMethod(ctx, "emoji.list", values, response)
	if err != nil {
		return nil, err
	}

	if response.Err() != nil {
		return nil, response.Err()
	}

	return response.Emoji, nil
}
396155
func (config StickerConfig) values() (url.Values, error) {
	v, err := config.BaseChat.values()
	if err != nil {
		return v, err
	}

	v.Add(config.name(), config.FileID)

	return v, nil
}
291833
func (j JsonHelper) Helpers(n string) []JsonHelper {
	v := j.Get(n)
	if v == nil {
		return nil
	}
	switch val := v.(type) {
	case []map[string]interface{}:
		hl := make([]JsonHelper, 0)
		for _, mapVal := range val {
			hl = append(hl, mapVal)
		}
		return hl
	case []interface{}:
		jhl := make([]JsonHelper, 0)
		for _, item := range val {
			if jh, ok := item.(map[string]interface{}); ok {
				jhl = append(jhl, jh)
			}
		}
		return jhl
	}

	return nil
}
1323066
func (c *Client) AddStickerToSetFile(userID int, name, filename, emojis string, opts ...sendOption) error {
	req := url.Values{}
	req.Set("user_id", fmt.Sprint(userID))
	req.Set("name", name)
	req.Set("emojis", emojis)
	for _, opt := range opts {
		opt(req)
	}
	var added bool
	return c.doRequestWithFiles("addStickerToSet", req, &added, inputFile{field: "png_sticker", name: filename})
}
448101
func (i *injector) NServices() int {
	if i.parent != nil {
		return len(i.services) + i.parent.NServices()
	}

	return len(i.services)
}
1358118
func (mrt MarkdownRichText) URL(text string, url string) string {
	repalcer := strings.NewReplacer("[", "⟦", "]", "⟧", "(", "❨", ")", "❩")
	text = fmt.Sprintf("[%s](%s)", repalcer.Replace(text), url)
	return text
}