Skip to content

Commit 8fc3f86

Browse files
committed
Add an emote list
It's ugly, but it get's the job done. This list will need to be improved a lot (ie, make it searchable and maybe even clickable emotes?). This is for #99, but should not be considered fixed yet.
1 parent 528b29e commit 8fc3f86

File tree

9 files changed

+64
-3
lines changed

9 files changed

+64
-3
lines changed

chatcommands.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ var commands = &CommandControl{
4040
Function: cmdHelp,
4141
},
4242

43+
common.CNEmotes.String(): Command{
44+
HelpText: "Display a list of available emotes.",
45+
Function: func(client *Client, args []string) (string, error) {
46+
client.SendChatData(common.NewChatCommand(common.CmdEmotes, []string{"/emotes"}))
47+
return "Opening emote list in new window.", nil
48+
},
49+
},
50+
4351
common.CNCount.String(): Command{
4452
HelpText: "Display number of users in chat.",
4553
Function: func(client *Client, args []string) (string, error) {

common/chatcommands.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var (
2323
CNNick ChatCommandNames = []string{"nick", "name"}
2424
CNStats ChatCommandNames = []string{"stats"}
2525
CNPin ChatCommandNames = []string{"pin", "password"}
26+
CNEmotes ChatCommandNames = []string{"emotes"}
2627
// Mod Commands
2728
CNSv ChatCommandNames = []string{"sv"}
2829
CNPlaying ChatCommandNames = []string{"playing"}
@@ -53,6 +54,7 @@ var ChatCommands = []ChatCommandNames{
5354
CNNick,
5455
CNStats,
5556
CNPin,
57+
CNEmotes,
5658

5759
// Mod
5860
CNSv,

common/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
CmdRefreshPlayer
3535
CmdPurgeChat
3636
CmdHelp
37+
CmdEmotes
3738
)
3839

3940
type CommandLevel int

common/templates.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ var isServer bool = false
1818

1919
// keys and files to load for that template
2020
var serverTemplateDefs map[string][]string = map[string][]string{
21-
"pin": []string{"./static/base.html", "./static/thedoor.html"},
22-
"main": []string{"./static/base.html", "./static/main.html"},
23-
"help": []string{"./static/base.html", "./static/help.html"},
21+
"pin": []string{"./static/base.html", "./static/thedoor.html"},
22+
"main": []string{"./static/base.html", "./static/main.html"},
23+
"help": []string{"./static/base.html", "./static/help.html"},
24+
"emotes": []string{"./static/base.html", "./static/emotes.html"},
2425
}
2526

2627
var chatTemplateDefs map[string]string = map[string]string{

handlers.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,23 @@ func handleHelpTemplate(w http.ResponseWriter, r *http.Request) {
271271
}
272272
}
273273

274+
func handleEmoteTemplate(w http.ResponseWriter, r *http.Request) {
275+
type Data struct {
276+
Title string
277+
Emotes map[string]string
278+
}
279+
280+
data := Data{
281+
Title: "Available Emotes",
282+
Emotes: common.Emotes,
283+
}
284+
285+
err := common.ExecuteServerTemplate(w, "emotes", data)
286+
if err != nil {
287+
common.LogErrorf("Error executing file, %v", err)
288+
}
289+
}
290+
274291
func handlePin(w http.ResponseWriter, r *http.Request) {
275292
session, err := sstore.Get(r, "moviesession")
276293
if err != nil {

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func startServer() {
130130
http.HandleFunc("/video", handleIndexTemplate)
131131
http.HandleFunc("/help", handleHelpTemplate)
132132
http.HandleFunc("/pin", handlePin)
133+
http.HandleFunc("/emotes", handleEmoteTemplate)
133134

134135
http.HandleFunc("/", handleDefault)
135136

static/css/site.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ input[type=text] {
109109
color: white;
110110
}
111111

112+
#emotesbody {
113+
color: var(--var-message-color);
114+
}
115+
116+
.emotedef {
117+
display: flex;
118+
flex-direction: row;
119+
}
120+
121+
.emotedef div {
122+
padding: 5px;
123+
}
124+
112125
.notice {
113126
color: #595959;
114127
font-size: 75%;

static/emotes.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{define "header"}}
2+
{{end}}
3+
4+
{{define "body"}}
5+
<div id="emotesbody">
6+
<h2>Available Emotes</h2>
7+
{{range $k, $v := .Emotes}}
8+
<div class="emotedef">
9+
<div><img src="{{$v}}" /></div>
10+
<div>{{$k}}</div>
11+
</div>
12+
{{end}}
13+
</div>
14+
{{end}}

wasm/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ func recieve(v []js.Value) {
148148
}
149149
appendMessage(d.HTML())
150150
global.Get("window").Call("open", url, "_blank", "menubar=0,status=0,toolbar=0,width=300,height=600")
151+
case common.CmdEmotes:
152+
url := "/emotes"
153+
appendMessage(d.HTML())
154+
global.Get("window").Call("open", url, "_blank", "menubar=0,status=0,toolbar=0,width=300,height=600")
151155
}
152156
}
153157
}

0 commit comments

Comments
 (0)