diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ae10e78..0000000 --- a/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ubuntu:15.10 -MAINTAINER Andreas Neue - -RUN apt-get -y --force-yes update -RUN apt-get -y --force-yes upgrade -RUN apt-get install -y ca-certificates -RUN apt-get install -y fortune vim -RUN apt-get clean - -RUN mkdir /flokatirc - -COPY flokatirc /flokatirc/flokatirc -COPY newsfeeds.conf /flokatirc/newsfeeds.conf -COPY fortunes /flokatirc/fortunes - -ENV PATH $PATH:/flokatirc - -WORKDIR /flokatirc - -CMD [ "/flokatirc/flokatirc", "-server=irc.dnix.de:6667", "-name=Flokati", "-chan=#test", "-nsname=N", "-nspass=t0ps3cr37" ] diff --git a/Makefile b/Makefile deleted file mode 100644 index 7d9e777..0000000 --- a/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -GOPATH := ${PWD}:${GOPATH} -export GOPATH - -default: build - -build: genversion genbuilddate test - go build -v flokatirc - -build-win: test genversion - GOOS=windows GOARCH=amd64 go build -v -o flokatirc.exe flokatirc - -docker: build - ./dockerbuild.sh - -genversion: - ./genversion.sh - -genbuilddate: - ./genbuilddate.sh - -fmt: - go fmt ./... - -fix: - go fix ./... - -imports: - find . -type f -name "*.go" -exec goimports -w {} \; - -doc: - godoc -http=:6060 -index - -test: - go test ./... - -commit: - git commit -a -F changes.log - rm changes.log - touch changes.log - ./genversion.sh - -push: - git push diff --git a/README.md b/README.md index 9c880f1..af82b94 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -## flokatirc +## flokatilib -*an incredibly friendly, silver-tongued, and elegantly proportioned IRC community bot* +*Modules and utilities for the incredibly friendly, silver-tongued, and elegantly proportioned community bot* #### LICENSE diff --git a/dockerbuild.sh-dist b/dockerbuild.sh-dist deleted file mode 100755 index 3b07f12..0000000 --- a/dockerbuild.sh-dist +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -VERSION=`git rev-parse --abbrev-ref HEAD` -BUILD=`git rev-list HEAD --count` -echo $VERSION-$BUILD -docker build -t dr.dnix.de/flokatirc:$VERSION-$BUILD -f Dockerfile . -docker push dr.dnix.de/flokatirc:$VERSION-$BUILD diff --git a/genbuilddate.sh b/genbuilddate.sh deleted file mode 100755 index 0e90cff..0000000 --- a/genbuilddate.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -BUILDDATEDIR="version" -BUILDDATEGO="version/builddate.go" -if [ ! -d "$BUILDDATEDIR" ]; then - mkdir $BUILDDATEDIR -fi -echo "package version" >$BUILDDATEGO -echo "" >>$BUILDDATEGO -echo "const (" >>$BUILDDATEGO -echo -n " FlokatiBuilddate = \"" >>$BUILDDATEGO -echo -n `date` >>$BUILDDATEGO -echo "\"" >>$BUILDDATEGO -echo ")" >>$BUILDDATEGO diff --git a/genversion.sh b/genversion.sh deleted file mode 100755 index c3c7c67..0000000 --- a/genversion.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -VERSIONDIR="version" -VERSIONGO="version/version.go" -if [ ! -d "$VERSIONDIR" ]; then - mkdir $VERSIONDIR -fi -echo "package version" >$VERSIONGO -echo "" >>$VERSIONGO -echo "const (" >>$VERSIONGO -echo -n " FlokatiVersion = \"" >>$VERSIONGO -echo -n `git rev-parse --abbrev-ref HEAD` >>$VERSIONGO -echo "\"" >>$VERSIONGO -echo -n " FlokatiBuild = \"" >>$VERSIONGO -echo -n `git rev-list HEAD --count` >>$VERSIONGO -echo "\"" >>$VERSIONGO -echo ")" >>$VERSIONGO diff --git a/main.go b/main.go deleted file mode 100644 index 666c480..0000000 --- a/main.go +++ /dev/null @@ -1,165 +0,0 @@ -// vi:ts=4:sts=4:sw=4:noet:tw=72 -// -// flokatirc -// -// Copyright (c) 2015,2016 Andreas Neue - -package main - -import ( - "flag" - "fmt" - "runtime" - "strings" - "time" - - "code.dnix.de/an/xlog" - - "github.com/nickvanw/ircx" - "github.com/sorcix/irc" - "github.com/sorcix/irc/ctcp" - - "flokatirc/modules" - "flokatirc/version" -) - -var ( - name = flag.String("name", "Flokati", "Nickname to use") - server = flag.String("server", "chat.freenode.org:6667", "Host:Port to connect to") - channels = flag.String("chan", "#test", "Channels to join") - nsname = flag.String("nsname", "NickServ", "NickServ name") - nspass = flag.String("nspass", "", "NickServ password") - mods = flag.String("mods", "", "Modules to load") - params = flag.String("params", "", "Module params") - autocmd = flag.String("autocmd", "", "Autosend IRC command") -) - -func init() { - flag.Parse() -} - -var ( - sayCh chan string -) - -func main() { - sayCh = make(chan string, 1024) - - xlog.Init(xlog.DEBUG) - - //bot := ircx.Classic(*server, *name) - cfg := ircx.Config{User: *name, MaxRetries: 1000} - bot := ircx.New(*server, *name, cfg) - xlog.Info("%s started", SoftwareInfo()) - xlog.Info("Logging in") - if err := bot.Connect(); err != nil { - xlog.Fatal("Unable to dial IRC Server: %v", err) - } - - //mods := strings.Split(*modules, ",") - //TODO: implement more robust list parsing - - modules.Init(sayCh, *mods, *params) - modules.ModParams["_nick"] = *name - - go func() { - for { - var targets string - line := strings.Split(<-sayCh, "\n") - if len(line) < 2 { - continue - } - if line[0] != "*" { - targets = line[0] - } else { - targets = *channels - } - for _, tar := range strings.Split(targets, ",") { - bot.Sender.Send(&irc.Message{ - Command: irc.PRIVMSG, - Params: []string{tar}, - Trailing: line[1], - }) - time.Sleep(1 * time.Second) - } - } - }() - - go Ping(bot) - if *autocmd != "" { - println(*autocmd) - bot.Sender.Send(&irc.Message{Command: *autocmd}) - } - RegisterHandlers(bot) - bot.HandleLoop() - xlog.Info("Exiting") -} - -func RegisterHandlers(bot *ircx.Bot) { - xlog.Info("Registering handlers") - bot.HandleFunc(irc.RPL_WELCOME, ConnectHandler) - bot.HandleFunc(irc.PING, PingHandler) - bot.HandleFunc(irc.PRIVMSG, PrivmsgHandler) -} - -func Ping(bot *ircx.Bot) { - for { - time.Sleep(1 * time.Minute) - bot.Sender.Send(&irc.Message{Command: irc.PING}) - } -} - -func ConnectHandler(s ircx.Sender, m *irc.Message) { - if *nspass != "" { - xlog.Info("Authenticating with NickServ: %v, %v", *name, *nspass) - s.Send(&irc.Message{ - Command: irc.PRIVMSG, - Params: []string{*nsname}, - Trailing: "IDENTIFY " + *name + " " + *nspass, - }) - } - xlog.Info("Joining channels: %v", *channels) - for _, ch := range strings.Split(*channels, ",") { - s.Send(&irc.Message{ - Command: irc.JOIN, - Params: []string{ch}, - }) - } - time.Sleep(2 * time.Second) - msg := ctcp.Action(fmt.Sprintf("running on %s", SoftwareInfo())) - sayCh <- fmt.Sprintf("%s\n%s", "*", msg) -} - -func PingHandler(s ircx.Sender, m *irc.Message) { - xlog.Info("PingPong") - s.Send(&irc.Message{ - Command: irc.PONG, - Params: m.Params, - Trailing: m.Trailing, - }) -} - -func PrivmsgHandler(s ircx.Sender, m *irc.Message) { - //TODO: implement message handler table - HandleMessage(m) - modules.HandleMessage(m) -} - -func HandleMessage(m *irc.Message) { - tok := strings.Split(m.Trailing, " ") - if len(tok) < 1 { - return - } - switch tok[0] { - case "!version": - msg := ctcp.Action(fmt.Sprintf("running on %s", SoftwareInfo())) - sayCh <- fmt.Sprintf("%s\n%s", "*", msg) - //sayCh <- fmt.Sprintf("%s\n%s", "*", SoftwareInfo()) - default: - } -} - -func SoftwareInfo() string { - return fmt.Sprintf("flokatirc %s-%s (built %s [%s])", version.FlokatiVersion, - version.FlokatiBuild, version.FlokatiBuilddate, runtime.Version()) -} diff --git a/newsfeeds.conf b/newsfeeds.conf deleted file mode 100644 index 68de158..0000000 --- a/newsfeeds.conf +++ /dev/null @@ -1 +0,0 @@ -https://example.com/rss