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 time1516import (17 "github.com/nmeum/marvin/irc"18 "github.com/nmeum/marvin/modules"19 "time"20)2122type Module struct {23 Format string `json:"format"`24}2526func Init(moduleSet *modules.ModuleSet) {27 moduleSet.Register(new(Module))28}2930func (m *Module) Name() string {31 return "time"32}3334func (m *Module) Help() string {35 return "USAGE: !time"36}3738func (m *Module) Defaults() {39 m.Format = time.RFC112340}4142func (m *Module) Load(client *irc.Client) error {43 client.CmdHook("privmsg", m.timeCmd)44 return nil45}4647func (m *Module) timeCmd(client *irc.Client, msg irc.Message) error {48 if msg.Data != "!time" {49 return nil50 }5152 now := time.Now().UTC()53 return client.Write("NOTICE %s :%s",54 msg.Receiver, now.Format(m.Format))55}