diff --git a/AutoBuild/Cargo.lock b/AutoBuild/Cargo.lock new file mode 100644 index 0000000..6cd267d --- /dev/null +++ b/AutoBuild/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "AutoBuild" +version = "0.1.0" diff --git a/AutoBuild/Cargo.toml b/AutoBuild/Cargo.toml new file mode 100644 index 0000000..d039c47 --- /dev/null +++ b/AutoBuild/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "AutoBuild" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "AutoBuild" +path = "main.rs" diff --git a/AutoBuild/go.mod b/AutoBuild/go.mod new file mode 100644 index 0000000..bf2ffce --- /dev/null +++ b/AutoBuild/go.mod @@ -0,0 +1,5 @@ +module autobuild + +go 1.18 + +require github.com/thoas/go-funk v0.9.2 // indirect diff --git a/AutoBuild/go.sum b/AutoBuild/go.sum new file mode 100644 index 0000000..be8c380 --- /dev/null +++ b/AutoBuild/go.sum @@ -0,0 +1,8 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/thoas/go-funk v0.9.2 h1:oKlNYv0AY5nyf9g+/GhMgS/UO2ces0QRdPKwkhY3VCk= +github.com/thoas/go-funk v0.9.2/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/AutoBuild/main.go b/AutoBuild/main.go index d2776b7..3c8c60c 100644 --- a/AutoBuild/main.go +++ b/AutoBuild/main.go @@ -1,14 +1,62 @@ package main +import ( + "log" + "reflect" + "time" +) + +type FilterList struct { + abp []string + hosts []string +} + +type HEAD struct { + abp string + hosts string +} + func main() { - type FilterList struct { - abp []string - hosts []string - } - filterlist := FilterList{ + filterlist := &FilterList{ []string{"experimental.txt", "filter.txt"}, []string{"hosts.txt", "nofarm_hosts.txt"}} - //fmt.Println(filterlist) + heads := HEAD{ + abp: "[Adblock Plus]\n" + + "! Title: LowTechFilter {name}\n" + + "! Version: {version}\n" + + "! Expires: 1 hour\n" + + "! Homepage: https://t.me/AdBlock_TW\n" + + "! ----------------------------------------------------------------------\n", + hosts: "! FutaHosts\n" + + "! LowTechFilter {name}\n" + + "! URL: \n" + + "! Version: {version}\n" + + "! --------------------------------------------------\n", + } + url := "https://filter.futa.gg/" + log.Println(url) + log.Println(heads) + + location, _ := time.LoadLocation("Asia/Taipei") + now := time.Now().In(location) + log.Println(now) + + //fields := reflect.VisibleFields(reflect.TypeOf(filterlist)) + v := reflect.ValueOf(filterlist).Elem() + log.Println(v.FieldByName("abp").s) + //for _, field := range fields { + // data := reflect.Indirect(v).FieldByName(field.Name) + // log.Println(data) + //} + log.Println(v) + menu := map[string][]string{ + "abp": {"experimental.txt", "filter.txt"}, + "hosts": {"hosts.txt", "nofarm_hosts.txt"}, + } + for category, data := range menu { + log.Println(category, data) + } + //log.Println(menu) } diff --git a/AutoBuild/main.rs b/AutoBuild/main.rs new file mode 100644 index 0000000..4d929a0 --- /dev/null +++ b/AutoBuild/main.rs @@ -0,0 +1,34 @@ +fn main() { + struct FilterList<'a> { + abp: Vec<&'a str>, + hosts: Vec<&'a str>, + } + struct HEAD<'a> { + abp: &'a str, + hosts: &'a str, + } + + let filterlist = FilterList { + abp: vec!["experimental.txt", "filter.txt"], + hosts: vec!["hosts.txt", "nofarm_hosts.txt"], + }; + let url: &str = "https://filter.futa.gg/"; + let head = HEAD { + abp: "[Adblock Plus]\n + ! Title: LowTechFilter {name}\n + ! Version: {version}\n + ! Expires: 1 hour\n + ! Homepage: https://t.me/AdBlock_TW\n + ! ----------------------------------------------------------------------\n", + hosts: "! FutaHosts\n\ + ! LowTechFilter {name}\n\ + ! URL: \n\ + ! Version: {version}\n\ + ! --------------------------------------------------\n", + }; + println!("{:?}", head.hosts); + for val in head { + println!("{:?}", val) + } + // println!("{:?}", filterlist::field_names()); +}