はじめます!

Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
2026-01-02 19:34:10 -03:00
commit ee6f23e787
8 changed files with 151 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/haruhi

12
README.md Normal file
View File

@@ -0,0 +1,12 @@
# Haruhi
The (currently non-functioning) IRC bot for the [Unofficial SOS Brigade](https://hikoushiki-sos-dan.host2go.net)'s IRC channel `#sos-dan`, take 3.
## License
THE UNOFFICIAL SOS BRIGADE PUBLIC LICENSE
--- Version 2 ---
You are allowed to do literally whatever you want to this code
provided you follow these conditions:
1. Acknowledge Haruhi Suzumiya as a god
2. You'll be her wallet

30
Taskfile.yml Normal file
View File

@@ -0,0 +1,30 @@
# https://taskfile.dev
version: '3'
env:
GO: go
GOTELEMETRY: off
vars:
IMPORT: git.laidback.moe/shinyoukai/haruhi
VERSION: 0.0.0
tasks:
default:
cmds:
- task: build
build:
desc: Build the bot
cmds:
- $GO build -v -ldflags='-w -X {{.IMPORT}}.Version=$VERSION' -buildvcs=false -o haruhi
silent: true
clean:
desc: Remove generated files
cmds:
- rm -f haruhi
silent: true
tidy:
desc: Update go.mod
cmds:
- $GO mod tidy
silent: true

36
config.go Normal file
View File

@@ -0,0 +1,36 @@
package main
import (
"log"
"os"
"gopkg.in/ini.v1"
)
var Config struct {
Channel string
Host string
Nick string
}
func ConfInit() {
config, err := os.UserConfigDir()
if err != nil {
log.Println("Unable to obtain user's configuration directory")
log.Fatal(err)
}
configPath := config + "/haruhi.ini"
Parse(configPath)
}
func Parse(file string) error {
cfg, err := ini.Load(file)
if err != nil {
return err
}
Config.Channel = cfg.Section("haruhi").Key("channel").String()
Config.Host = cfg.Section("haruhi").Key("host").String()
Config.Nick = cfg.Section("haruhi").Key("nick").String()
return nil
}

10
go.mod Normal file
View File

@@ -0,0 +1,10 @@
module git.laidback.moe/shinyoukai/haruhi
go 1.25.2
require (
golang.zx2c4.com/irc v0.0.0-20211018023802-6d08d74c58ff
gopkg.in/ini.v1 v1.67.0
)
require github.com/stretchr/testify v1.8.0 // indirect

18
go.sum Normal file
View File

@@ -0,0 +1,18 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
golang.zx2c4.com/irc v0.0.0-20211018023802-6d08d74c58ff h1:SxDqMvV5GQ0YrUGCOOJxEnjV+mEP0FTcD9AhyK8yQDk=
golang.zx2c4.com/irc v0.0.0-20211018023802-6d08d74c58ff/go.mod h1:dYOYwwLlPFLQ7C5+M6V39tdhXMiD2JEDXIpQiUgz+Do=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

27
main.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"fmt"
"golang.zx2c4.com/irc/hbot"
"strings"
"time"
)
func init() {
ConfInit()
}
func main() {
bot := hbot.NewBot(&hbot.Config{
Host: string(Config.Host),
Nick: string(Config.Nick),
Channels: strings.Split(Config.Channel, ","),
})
fmt.Println("Starting haruhi")
fmt.Printf("-- Version: %s -- \n", FullVersion())
fmt.Printf("Joining %s as %s at %s\n", Config.Host, Config.Nick, Config.Channel)
for {
bot.Run()
time.Sleep(time.Second + 5)
}
}

17
version.go Normal file
View File

@@ -0,0 +1,17 @@
package main
import (
"fmt"
)
var (
Revision = "0"
Version = "0"
)
func FullVersion() string {
return fmt.Sprintf("%s (r%s)", Version, Revision)
}
func PrintVersion() string {
return fmt.Sprintf("%s", Version)
}