diff --git a/cmd/chen/main.go b/cmd/chen/main.go deleted file mode 100644 index 97609c1..0000000 --- a/cmd/chen/main.go +++ /dev/null @@ -1,51 +0,0 @@ -package main - -import ( - "flag" - "log" - "gopkg.in/ini.v1" - - "git.chaotic.ninja/yakumo_izuru/chen" - "github.com/jbuchbinder/go-xmppbot" -) - -var config struct { - jid string - password string - prefix string - nick string - autojoin string -} - -var confFile string - -func init() { - flag.StringVar(&confFile, "f", "", "Configuration file") -} - -func readConf(file string) error { - cfg, err := ini.Load(file) - - if err != nil { - return err - } - - config.jid = cfg.Section("chen").Key("jid").String() - config.password = cfg.Section("chen").Key("password").String() - config.prefix = cfg.Section("chen").Key("prefix").String() - config.nick = cfg.Section("chen").Key("nick").String() - config.autojoin = cfg.Section("chen").Key("autojoin").String() - - return nil -} - -func main() { - flag.Parse() - if confFile != "" { - log.Println("Loading configuration file for Chen") - readConf(confFile) - } else { - log.Fatal("No configuration file has been provided") - } - log.Printf("Chen v%s starting with config %s\n", chen.FullVersion(), confFile) -} diff --git a/go.mod b/go.mod deleted file mode 100644 index f694f4f..0000000 --- a/go.mod +++ /dev/null @@ -1,13 +0,0 @@ -module git.chaotic.ninja/yakumo_izuru/chen - -go 1.20 - -require ( - github.com/jbuchbinder/go-xmppbot v0.0.0-20201202211837-603b6f40c1d1 - gopkg.in/ini.v1 v1.67.0 -) - -require ( - github.com/mattn/go-xmpp v0.0.0-20190124093244-6093f50721ed // indirect - github.com/stretchr/testify v1.9.0 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index 393874a..0000000 --- a/go.sum +++ /dev/null @@ -1,11 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/jbuchbinder/go-xmppbot v0.0.0-20201202211837-603b6f40c1d1 h1:D/19k3fV0YtcD2fot8lEqgPbY4xtRD+rck/IgWE23Z4= -github.com/jbuchbinder/go-xmppbot v0.0.0-20201202211837-603b6f40c1d1/go.mod h1:eWgqRsgB8cZqUd3VM03fsFR5Xmzqto5148/GO6WLPBk= -github.com/mattn/go-xmpp v0.0.0-20190124093244-6093f50721ed h1:A1hEQg5M0b3Wg06pm3q/B0wdZsPjVQ/a2IgauQ8wCZo= -github.com/mattn/go-xmpp v0.0.0-20190124093244-6093f50721ed/go.mod h1:Cs5mF0OsrRRmhkyOod//ldNPOwJsrBvJ+1WRspv0xoc= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/main.py b/main.py index 9c1c86f..3f348cf 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ from collections import defaultdict from slixmpp import ClientXMPP from urllib.parse import urlparse, parse_qs, urlunparse from pantomime import normalize_mimetype -import cgi +import ecgi parser = "html.parser" user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:10.0)" @@ -124,7 +124,7 @@ class ChenBot(ClientXMPP): content_disposition = r.headers.get("content-disposition") filename = None if content_disposition: - _, params = cgi.parse_header(content_disposition) + _, params = ecgi.parse_header(content_disposition) filename = params.get("filename") else: filename = os.path.basename(uri.path) diff --git a/requirements.txt b/requirements.txt index e4dd893..9b9d03a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ slixmpp beautifulsoup4 pantomime aiohttp +git+https://git.chaotic.ninja/yakumo.izuru/ecgi#egg=ecgi diff --git a/version.go b/version.go deleted file mode 100644 index f7b20e8..0000000 --- a/version.go +++ /dev/null @@ -1,50 +0,0 @@ -package chen - -import ( - "fmt" - "runtime/debug" - "strings" -) - -const ( - defaultVersion = "0.0.0" - defaultCommit = "HEAD" - defaultBuild = "0000-01-01:00:00+00:00" -) - -var ( - // Version is the tagged release version in the form .. - // following semantic versioning and is overwritten by the build system. - Version = defaultVersion - - // Commit is the commit sha of the build (normally from Git) and is overwritten - // by the build system. - Commit = defaultCommit - - // Build is the date and time of the build as an RFC3339 formatted string - // and is overwritten by the build system. - Build = defaultBuild -) - -// FullVersion display the full version and build -func FullVersion() string { - var sb strings.Builder - - isDefault := Version == defaultVersion && Commit == defaultCommit && Build == defaultBuild - - if !isDefault { - sb.WriteString(fmt.Sprintf("%s@%s %s", Version, Commit, Build)) - } - - if info, ok := debug.ReadBuildInfo(); ok { - if isDefault { - sb.WriteString(fmt.Sprintf(" %s", info.Main.Version)) - } - sb.WriteString(fmt.Sprintf(" %s", info.GoVersion)) - if info.Main.Sum != "" { - sb.WriteString(fmt.Sprintf(" %s", info.Main.Sum)) - } - } - - return sb.String() -}