// New bot instance.
// "nick" is optional if you did not specify it, a random one is generated for you.
// A successful call returns err == nil.
16597
func New(user, key string, nick ...string) (s *Session, err error) {
	var sessionName string
	if len(nick) > 0 {
		sessionName = nick[0]
	}

	s = &Session{
		User: user,
		Key:  key,
		Nick: sessionName,
	}

	params, err := json.Marshal(s)
	if err != nil {
		return
	}

	response, err := http.Post(createURL, "application/json", bytes.NewBuffer(params))
	if err != nil {
		return
	}

	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return
	}

	m := map[string]string{}
	err = json.Unmarshal([]byte(body), &m)
	if err != nil {
		return
	}

	if m["status"] == "success" {
		s.Nick = m["nick"]
	} else {
		err = fmt.Errorf(m["status"])
		return
	}

	return
}
706931
func New(node *neutrino.ChainService, spendHintCache chainntnfs.SpendHintCache,
	confirmHintCache chainntnfs.ConfirmHintCache) *NeutrinoNotifier {

	return &NeutrinoNotifier{
		notificationCancels:  make(chan interface{}),
		notificationRegistry: make(chan interface{}),

		blockEpochClients: make(map[uint64]*blockEpochRegistration),

		p2pNode:   node,
		chainConn: &NeutrinoChainConn{node},

		rescanErr: make(chan error),

		chainUpdates: queue.NewConcurrentQueue(10),
		txUpdates:    queue.NewConcurrentQueue(10),

		spendHintCache:   spendHintCache,
		confirmHintCache: confirmHintCache,

		quit: make(chan struct{}),
	}
}
535
func NewKey() (*[SecretKeyLength]byte, error) {
	// get 32-bytes of random from /dev/urandom
	bytes, err := randomProvider.Bytes(SecretKeyLength)
	if err != nil {
		return nil, fmt.Errorf("unable to generate random: %v", err)
	}

	return KeySliceToArray(bytes)
}
343807
func New(code int, msg string, args ...interface{}) *APIError {
	if code <= 0 {
		code = 500
	}

	if len(args) > 0 {
		return &APIError{code: code, msg: fmt.Sprintf(msg, args...)}
	}
	return &APIError{code: code, msg: msg}
}
210354
func New(h *Handlers, bc *Config) *Bot {
	if h.Errored == nil {
		h.Errored = logErrorHandler
	}

	b := &Bot{
		handlers:   h,
		cron:       cron.New(),
		msgsToSend: make(chan responseMessage, MsgBuffer),
		done:       make(chan struct{}),
		Protocol:   bc.Protocol,
		Server:     bc.Server,
	}

	// Launch the background goroutine that isolates the possibly non-threadsafe
	// message sending logic of the underlying transport layer.
	go b.processMessages()

	b.startMessageStreams()

	b.startPeriodicCommands()
	return b
}
302718
func New(c *client.Client, appID string, domain string) (api.Domain, error) {
	u := fmt.Sprintf("/v1/apps/%s/domains/", appID)

	req := api.DomainCreateRequest{Domain: domain}

	body, err := json.Marshal(req)

	if err != nil {
		return api.Domain{}, err
	}

	resBody, err := c.BasicRequest("POST", u, body)

	if err != nil {
		return api.Domain{}, err
	}

	res := api.Domain{}
	if err = json.Unmarshal([]byte(resBody), &res); err != nil {
		return api.Domain{}, err
	}

	return res, nil
}
329596
func New() hash.Hash {
	if blockfunc != blockfuncGeneric {
		d := new(digest)
		d.Reset()
		return d
	}
	// Fallback to the standard golang implementation
	// if no features were found.
	return sha256.New()
}
1263883
func CreateNoError(t *testing.T, ctx context.Context, client client.APIClient, name string, ops ...func(*types.NetworkCreate)) string { // nolint: golint
	t.Helper()

	name, err := createNetwork(ctx, client, name, ops...)
	assert.NilError(t, err)
	return name
}
230239
func (factory *NagiosBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := NagiosBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.services = make(map[string]map[string]service)
	bee.ReloadOptions(options)

	return &bee
}
1338960
func NewConfig(nick string, args ...string) *Config {
	cfg := &Config{
		Me:       &state.Nick{Nick: nick},
		PingFreq: 3 * time.Minute,
		NewNick:  func(s string) string { return s + "_" },
		Recover:  (*Conn).LogPanic, // in dispatch.go
		SplitLen: defaultSplit,
		Timeout:  60 * time.Second,
	}
	cfg.Me.Ident = "goirc"
	if len(args) > 0 && args[0] != "" {
		cfg.Me.Ident = args[0]
	}
	cfg.Me.Name = "Powered by GoIRC"
	if len(args) > 1 && args[1] != "" {
		cfg.Me.Name = args[1]
	}
	cfg.Version = "Powered by GoIRC"
	cfg.QuitMessage = "GoBye!"
	return cfg
}
301786
func New() *AnonUUID {
	return &AnonUUID{
		cache:    make(map[string]string),
		Hexspeak: false,
		Random:   false,
	}
}
1180996
func New(url string) (ws *WebSocket, err error) {
	defer func() {
		e := recover()
		if e == nil {
			return
		}
		if jsErr, ok := e.(*js.Error); ok && jsErr != nil {
			ws = nil
			err = jsErr
		} else {
			panic(e)
		}
	}()

	object := js.Global.Get("WebSocket").New(url)

	ws = &WebSocket{
		Object: object,
	}

	return
}
303657
func New(network, addr string) (client *Client, err error) {
	client = &Client{
		net:             network,
		addr:            addr,
		respHandler:     newResponseHandlerMap(),
		innerHandler:    newResponseHandlerMap(),
		in:              make(chan *Response, queueSize),
		ResponseTimeout: DefaultTimeout,
	}
	client.conn, err = net.Dial(client.net, client.addr)
	if err != nil {
		return
	}
	client.rw = bufio.NewReadWriter(bufio.NewReader(client.conn),
		bufio.NewWriter(client.conn))
	go client.readLoop()
	go client.processLoop()
	return
}
688536
func NewBot(c BotConfig) (Bot, error) {
	cli, err := newClient(clientConfig{agent: c.Agent, app: c.App})
	r := newReaper(
		reaperConfig{
			client:   cli,
			parser:   newParser(),
			hostname: "oauth.reddit.com",
			tls:      true,
			rate:     maxOf(c.Rate, time.Second),
		},
	)
	return &bot{
		Account: newAccount(r),
		Lurker:  newLurker(r),
		Scanner: newScanner(r),
	}, err
}
947919
func NewPopulatedNwkSKey(r Rand) (key *NwkSKey) {
	key = &NwkSKey{}
	if _, err := randRead(r, key[:]); err != nil {
		panic(fmt.Errorf("types.NewPopulatedNwkSKey: %s", err))
	}
	return
}
132717
func (bot *TgBot) NewPhotoChatFn(f func(TgBot, Message, int, string)) *TgBot {
	bot.addToConditionalFuncs(NewPhotoConditionalCall{f})
	return bot
}
1198297
func NewBotAPIWithClient(token string, client *http.Client) (*BotAPI, error) {
	bot := &BotAPI{
		Token:  token,
		Client: client,
		Buffer: 100,
		shutdownChannel: make(chan interface{}),
	}

	self, err := bot.GetMe()
	if err != nil {
		return nil, err
	}

	bot.Self = self

	return bot, nil
}