Initial commit

This commit is contained in:
an 2017-06-28 12:23:37 +02:00
parent 745bfc8d2b
commit fe8343300a
5 changed files with 166 additions and 4 deletions

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM ubuntu:15.10
MAINTAINER Andreas Neue <an@dnix.de>
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" ]

20
LICENSE
View File

@ -1,8 +1,20 @@
MIT License
Copyright (c) <year> <copyright holders>
Copyright (c) 2017 Andreas Neue <an@dnix.de>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

43
Makefile Normal file
View File

@ -0,0 +1,43 @@
GOPATH := ${PWD}:${GOPATH}
export GOPATH
default: build
build: genversion genbuilddate test
go build -v mmflokati
build-win: test genversion
GOOS=windows GOARCH=amd64 go build -v -o mmflokati.exe mmflokati
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

6
dockerbuild.sh-dist Executable file
View File

@ -0,0 +1,6 @@
#!/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

81
main.go Normal file
View File

@ -0,0 +1,81 @@
// vi:ts=4:sts=4:sw=4:noet:tw=72
//
// flokatirc
//
// Copyright (c) 2015,2016 Andreas Neue <an@dnix.de>
package main
import (
"flag"
"strings"
"time"
"code.dnix.de/an/xlog"
//"flokatirc/version"
//"code.dnix.de/an/flokatilib/modules"
"github.com/42wim/matterbridge/matterclient"
)
var (
name = flag.String("name", "matterbot", "Bot name")
pass = flag.String("pass", "", "Password")
team = flag.String("team", "", "Team name")
server = flag.String("server", "mm.example.com", "Server address")
mods = flag.String("mods", "", "Modules to load")
)
func init() {
flag.Parse()
}
var (
sayCh chan string
)
func main() {
sayCh = make(chan string, 1024)
xlog.Init(xlog.DEBUG)
//xlog.Info("%s started", SoftwareInfo())
xlog.Info("Started")
xlog.Info("Connecting ...")
bot := matterclient.New(*name, *pass, *team, *server)
err := bot.Login()
if err != nil {
xlog.Error(err.Error())
}
xlog.Info("Connected")
//mods := strings.Split(*modules, ",")
//TODO: implement more robust list parsing
//modules.Init(sayCh, *mods, *params)
//modules.ModParams["_nick"] = *name
for {
var targets string
line := strings.Split(<-sayCh, "\n")
if len(line) < 2 {
continue
}
targets = line[0]
for _, tar := range strings.Split(targets, ",") {
teamId := bot.GetTeamId()
chId := bot.GetChannelId(tar, teamId)
bot.PostMessage(chId, line[1])
}
time.Sleep(1 * time.Second)
}
}
//func SoftwareInfo() string {
// return fmt.Sprintf("flokatirc %s-%s (built %s [%s])", version.FlokatiVersion,
// version.FlokatiBuild, version.FlokatiBuilddate, runtime.Version())
//}