-
Notifications
You must be signed in to change notification settings - Fork 2
/
msg.go
121 lines (95 loc) · 2.32 KB
/
msg.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// All messages to the user should be defined here.
package main
import (
"fmt"
"strings"
"time"
)
func away() {
info("You are now away.")
}
func back() {
info("Welcome back.")
}
func notarget() {
warn("Join a channel first.")
}
func noconnection() {
warn("Not connected to a server.")
}
func connecting(server string, usetls bool) {
line := fmt.Sprintf("Connecting to %v", server)
if usetls {
line = line + " using TLS..."
} else {
line = line + " ..."
}
info(line)
}
func nick(oldnick string, newnick string) {
info(oldnick + " is now known as " + newnick)
// Forget old nick and remember the new one.
delete(commands.State.NickMap, oldnick)
commands.State.NickMap[newnick] = newnick
}
func connectionerror(err error) {
line := fmt.Sprintf("Connection error: %v", err)
errormsg(line)
}
func disconnected() {
warn("Disconnected from server.")
}
func connected(nick string) {
info("Connected as " + nick)
}
func msg(time time.Time, nick string, target string, text string, action bool) {
showmsg(nick, target, text, action)
}
func iquit() {
info("Quitting.")
}
func quit(nick string) {
if statusEvents {
line := fmt.Sprintf("%v quit IRC.", nick)
info(line)
}
delete(commands.State.NickMap, nick)
}
func notice(nick string, msg string) {
line := fmt.Sprintf("NOTICE: %v %v", nick, msg)
info(line)
}
func whois(nick string, realname string, ident string, host string) {
line := fmt.Sprintf("%s is %s <%s@%s>", nick, realname, ident, host)
info(line)
}
func joined(nick string, channel string) {
if statusEvents {
line := fmt.Sprintf("%s joined %s", nick, channel)
info(line)
}
// Remember this nick.
commands.State.NickMap[nick] = nick
}
func parted(nick string, channel string) {
if statusEvents {
line := fmt.Sprintf("%v parted %v", nick, channel)
info(line)
}
// Forget about this nick.
delete(commands.State.NickMap, nick)
}
func cantopenfile(filename string, err error) {
fmt.Printf("Could not open file '%s', will not write to log\n", filename)
fmt.Printf("Error Message: %s\n", err)
}
func members(channel string, members string) {
line := fmt.Sprintf("Members on %v: %v", channel, members)
info(line)
// Remember these nicks for completion.
fields := strings.Fields(members)
for _, field := range fields {
field = strings.Trim(field, "@")
commands.State.NickMap[field] = field
}
}