X-Git-Url: http://www.git.cypherpunks.ru/?p=goircd.git;a=blobdiff_plain;f=room.go;h=4bdb4b2f18427c728c762d74b85e6149bc7215f2;hp=3f8901caf894732e369863b8c514f6bfe62e84be;hb=186ec4b4bd91f9fd101b2f62d30c0f2bd4ed50ce;hpb=cfeaaad88f71bf1b0846251b7f448bf41bde26d9 diff --git a/room.go b/room.go index 3f8901c..4bdb4b2 100644 --- a/room.go +++ b/room.go @@ -1,6 +1,6 @@ /* goircd -- minimalistic simple Internet Relay Chat (IRC) server -Copyright (C) 2014 Sergey Matveev +Copyright (C) 2014-2015 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,6 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ + package main import ( @@ -41,12 +42,16 @@ type Room struct { topic string key string members map[*Client]bool - hostname string + hostname *string logSink chan<- LogEvent stateSink chan<- StateEvent } -func NewRoom(hostname, name string, logSink chan<- LogEvent, stateSink chan<- StateEvent) *Room { +func (room Room) String() string { + return room.name +} + +func NewRoom(hostname *string, name string, logSink chan<- LogEvent, stateSink chan<- StateEvent) *Room { room := Room{name: name} room.members = make(map[*Client]bool) room.topic = "" @@ -120,11 +125,25 @@ func (room *Room) Processor(events <-chan ClientEvent) { room.topic = strings.TrimLeft(event.text, ":") msg := fmt.Sprintf(":%s TOPIC %s :%s", client, room.name, room.topic) go room.Broadcast(msg) - room.logSink <- LogEvent{room.name, client.nickname, "set topic to " + room.topic, true} + room.logSink <- LogEvent{ + room.name, + client.nickname, + "set topic to " + room.topic, + true, + } room.StateSave() case EventWho: for m := range room.members { - client.ReplyNicknamed("352", room.name, m.username, m.conn.RemoteAddr().String(), room.hostname, m.nickname, "H", "0 "+m.realname) + client.ReplyNicknamed( + "352", + room.name, + m.username, + m.conn.RemoteAddr().String(), + *room.hostname, + m.nickname, + "H", + "0 "+m.realname, + ) } client.ReplyNicknamed("315", room.name, "End of /WHO list") case EventMode: @@ -136,6 +155,10 @@ func (room *Room) Processor(events <-chan ClientEvent) { client.Msg(fmt.Sprintf("324 %s %s %s", client.nickname, room.name, mode)) continue } + if strings.HasPrefix(event.text, "b") { + client.ReplyNicknamed("368", room.name, "End of channel ban list") + continue + } if strings.HasPrefix(event.text, "-k") || strings.HasPrefix(event.text, "+k") { if _, subscribed := room.members[client]; !subscribed { client.ReplyParts("442", room.name, "You are not on that channel") @@ -166,8 +189,20 @@ func (room *Room) Processor(events <-chan ClientEvent) { room.StateSave() case EventMsg: sep := strings.Index(event.text, " ") - room.Broadcast(fmt.Sprintf(":%s %s %s :%s", client, event.text[:sep], room.name, event.text[sep+1:]), client) - room.logSink <- LogEvent{room.name, client.nickname, event.text[sep+1:], false} + room.Broadcast(fmt.Sprintf( + ":%s %s %s :%s", + client, + event.text[:sep], + room.name, + event.text[sep+1:]), + client, + ) + room.logSink <- LogEvent{ + room.name, + client.nickname, + event.text[sep+1:], + false, + } } } }