1// This program is free software: you can redistribute it and/or modify 2// it under the terms of the GNU Affero General Public License as 3// published by the Free Software Foundation, either version 3 of the 4// License, or (at your option) any later version. 5// 6// This program is distributed in the hope that it will be useful, but 7// WITHOUT ANY WARRANTY; without even the implied warranty of 8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9// Affero General Public License for more details.10//11// You should have received a copy of the GNU Affero General Public12// License along with this program. If not, see <http://www.gnu.org/licenses/>.1314package nickserv1516import (17 "github.com/nmeum/marvin/irc"18 "github.com/nmeum/marvin/modules"19 "strings"20)2122type Module struct {23 NickServ string `json:"nickserv"`24 Password string `json:"password"`25 Keyword string `json:"keyword"`26}2728func Init(moduleSet *modules.ModuleSet) {29 moduleSet.Register(new(Module))30}3132func (m *Module) Name() string {33 return "nickserv"34}3536func (m *Module) Help() string {37 return "Enables authentication with NickServ."38}3940func (m *Module) Defaults() {41 m.NickServ = "NickServ"42 m.Keyword = "identify"43}4445func (m *Module) Load(client *irc.Client) error {46 if len(m.Password) <= 0 {47 return nil48 }4950 client.CmdHook("notice", func(c *irc.Client, msg irc.Message) error {51 if msg.Sender.Name != m.NickServ || !strings.Contains(msg.Data, m.Keyword) {52 return nil53 }5455 return c.Write("PRIVMSG %s :identify %s",56 m.NickServ, m.Password)57 })5859 return nil60}