mirror of
https://github.com/jech/galene.git
synced 2024-11-25 18:15:57 +01:00
Add command /clear.
This commit is contained in:
parent
fd1772ed72
commit
10526d474e
3 changed files with 25 additions and 0 deletions
|
@ -1061,6 +1061,13 @@ func handleClientMessage(c *client, m clientMessage) error {
|
||||||
for _, cc := range clients {
|
for _, cc := range clients {
|
||||||
cc.write(m)
|
cc.write(m)
|
||||||
}
|
}
|
||||||
|
case "clearchat":
|
||||||
|
c.group.clearChatHistory()
|
||||||
|
m := clientMessage{Type: "clearchat"}
|
||||||
|
clients := c.group.getClients(nil)
|
||||||
|
for _, cc := range clients {
|
||||||
|
cc.write(m)
|
||||||
|
}
|
||||||
case "op", "unop", "present", "unpresent":
|
case "op", "unop", "present", "unpresent":
|
||||||
if !c.permissions.Op {
|
if !c.permissions.Op {
|
||||||
c.error(userError("not authorised"))
|
c.error(userError("not authorised"))
|
||||||
|
|
6
group.go
6
group.go
|
@ -361,6 +361,12 @@ func (g *group) Range(f func(c *client) bool) {
|
||||||
|
|
||||||
const maxChatHistory = 20
|
const maxChatHistory = 20
|
||||||
|
|
||||||
|
func (g *group) clearChatHistory() {
|
||||||
|
g.mu.Lock()
|
||||||
|
defer g.mu.Unlock()
|
||||||
|
g.history = nil
|
||||||
|
}
|
||||||
|
|
||||||
func (g *group) addToChatHistory(id, user, value string, me bool) {
|
func (g *group) addToChatHistory(id, user, value string, me bool) {
|
||||||
g.mu.Lock()
|
g.mu.Lock()
|
||||||
defer g.mu.Unlock()
|
defer g.mu.Unlock()
|
||||||
|
|
|
@ -435,6 +435,9 @@ function serverConnect() {
|
||||||
case 'chat':
|
case 'chat':
|
||||||
addToChatbox(m.id, m.username, m.value, m.me);
|
addToChatbox(m.id, m.username, m.value, m.me);
|
||||||
break;
|
break;
|
||||||
|
case 'clearchat':
|
||||||
|
resetChat();
|
||||||
|
break;
|
||||||
case 'ping':
|
case 'ping':
|
||||||
send({
|
send({
|
||||||
type: 'pong',
|
type: 'pong',
|
||||||
|
@ -750,6 +753,15 @@ function handleInput() {
|
||||||
case '/leave':
|
case '/leave':
|
||||||
socket.close();
|
socket.close();
|
||||||
return;
|
return;
|
||||||
|
case '/clear':
|
||||||
|
if(!permissions.op) {
|
||||||
|
displayError("You're not an operator");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
send({
|
||||||
|
type: 'clearchat',
|
||||||
|
});
|
||||||
|
return;
|
||||||
case '/op':
|
case '/op':
|
||||||
case '/unop':
|
case '/unop':
|
||||||
case '/kick':
|
case '/kick':
|
||||||
|
|
Loading…
Reference in a new issue