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)
|
oldTopic := m.GetTopic(target)
|
||||||
oldTopicParts := strings.Split(oldTopic, "|")
|
oldTopicParts := strings.Split(oldTopic, "|")
|
||||||
|
|
||||||
|
@ -350,6 +350,14 @@ func main() {
|
||||||
default:
|
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) {
|
conn.AddCallback("INVITE", func(e *irc.Event) {
|
||||||
// Allow invites?
|
// Allow invites?
|
||||||
if !allowInvite {
|
if !allowInvite {
|
||||||
|
|
|
@ -6,6 +6,14 @@ func (m *Manager) initTopic() {
|
||||||
m.topicMap = map[string]string{}
|
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) {
|
func (m *Manager) GetTopic(channel string) (retval string) {
|
||||||
channel = strings.ToLower(channel)
|
channel = strings.ToLower(channel)
|
||||||
m.topicStateLock.RLock()
|
m.topicStateLock.RLock()
|
||||||
|
@ -20,3 +28,10 @@ func (m *Manager) SaveTopic(channel string, topic string) {
|
||||||
defer m.topicStateLock.Unlock()
|
defer m.topicStateLock.Unlock()
|
||||||
m.topicMap[channel] = topic
|
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