Fix bad channel management for topic changes.
parent
ded03116cc
commit
081d354bab
10
main.go
10
main.go
|
@ -167,7 +167,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
for _, target := range channels {
|
||||
for _, target := range m.GetChannels() {
|
||||
oldTopic := m.GetTopic(target)
|
||||
oldTopicParts := strings.Split(oldTopic, "|")
|
||||
|
||||
|
@ -350,6 +350,14 @@ func main() {
|
|||
default:
|
||||
}
|
||||
})
|
||||
conn.AddCallback("PART", func(e *irc.Event) {
|
||||
// Is this PART not about us?
|
||||
if !strings.EqualFold(e.Nick, conn.GetNick()) {
|
||||
return
|
||||
}
|
||||
|
||||
m.DeleteTopic(e.Arguments[0])
|
||||
})
|
||||
conn.AddCallback("INVITE", func(e *irc.Event) {
|
||||
// Allow invites?
|
||||
if !allowInvite {
|
||||
|
|
|
@ -6,6 +6,14 @@ func (m *Manager) initTopic() {
|
|||
m.topicMap = map[string]string{}
|
||||
}
|
||||
|
||||
func (m *Manager) GetChannels() (channels []string) {
|
||||
channels = []string{}
|
||||
for name, _ := range m.topicMap {
|
||||
channels = append(channels, name)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Manager) GetTopic(channel string) (retval string) {
|
||||
channel = strings.ToLower(channel)
|
||||
m.topicStateLock.RLock()
|
||||
|
@ -20,3 +28,10 @@ func (m *Manager) SaveTopic(channel string, topic string) {
|
|||
defer m.topicStateLock.Unlock()
|
||||
m.topicMap[channel] = topic
|
||||
}
|
||||
|
||||
func (m *Manager) DeleteTopic(channel string) {
|
||||
channel = strings.ToLower(channel)
|
||||
m.topicStateLock.Lock()
|
||||
defer m.topicStateLock.Unlock()
|
||||
delete(m.topicMap, channel)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue