Repository navigation
Expand file tree
/
Copy pathdoc.go
More file actions
43 lines (43 loc) · 1.48 KB
/
Copy pathdoc.go
File metadata and controls
43 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Package nerimity is a client SDK for the Nerimity chat platform
// (https://nerimity.com), functionally equivalent to the official JavaScript
// SDK, @nerimity/nerimity.js.
//
// # Quickstart
//
// client := nerimity.New(nerimity.Options{})
//
// client.OnReady(func() {
// log.Printf("connected as %s", client.User().Username)
// })
//
// client.OnMessageCreate(func(m *nerimity.Message) {
// if m.User.ID == client.User().ID {
// return
// }
// if m.Content == "!ping" {
// m.Reply(context.Background(), "Pong!")
// }
// })
//
// if err := client.Login("bot token here"); err != nil {
// log.Fatal(err)
// }
//
// # Events
//
// Handlers are registered with typed On* methods on Client (OnReady,
// OnMessageCreate, OnMessageButtonClick, and so on) rather than a single
// stringly-typed dispatch method. This keeps handler signatures discoverable
// via godoc and type-checked at compile time. Multiple handlers may be
// registered for the same event; they run in registration order on a single
// internal dispatch goroutine, so handler code does not need its own
// synchronization to safely read the client's caches.
//
// Login blocks the calling goroutine, running the connection (with automatic
// reconnect) until Close is called or its context is cancelled. Run it in your
// program's main goroutine, or in its own goroutine if you need main for
// something else.
//
// See docs/events.md for the full event list and docs/getting-started.md for
// a longer walkthrough.
package nerimity