diff --git a/.idea/dictionaries/qbit.xml b/.idea/dictionaries/qbit.xml index c50012d..9bd5f24 100644 --- a/.idea/dictionaries/qbit.xml +++ b/.idea/dictionaries/qbit.xml @@ -1,7 +1,120 @@ + adressing + akesi + alasa + animally + anpa + appid + awen + bluey + botsnack + callsign + chronologic + covid + datas + descr + diskv + errorf + esun + feder + gomatrix + hawkard + highfives + highfiving + insa + jaki + jelo + kalama + kasi + kepeken + kili + kiwen + kule + kulupu + kute + lape + laso + lawa + lete + lili + linja + lipu + liquify + loje + luka + lukin + lupa + mcchunkie + mctest + meli + metaphorisch + mije + moar + moku + moli + monsi + muddler + mumsy + musi + namako + nanpa + nasin + nena + nimi + nois + noka + openweathermap + pakala + pali + palisa + pana + pilin + pimeja + pini + pipi + poka + poki + pona + regexes + retrives + sama + seli + selo + seme + sewi + sijelo + sike + sina + sinpin + sitelen + sona + soweli + sprintf + statuse + storer + suli + sunnily + suno + supa + suwi + tacticle + taso + tawa + telo + tenpo + thebigboard + toki + tomo + unpa + utala + vegetal veryhigh + walo + waso + wawa + wett \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..c260709 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/.idea/mcchunkie.iml b/.idea/mcchunkie.iml index 5e764c4..3cd41b9 100644 --- a/.idea/mcchunkie.iml +++ b/.idea/mcchunkie.iml @@ -2,7 +2,9 @@ - + + + diff --git a/main.go b/main.go index 83db7c9..f28b4e6 100644 --- a/main.go +++ b/main.go @@ -19,8 +19,7 @@ import ( const header = ` # mcchunkie -[![builds.sr.ht status](https://builds.sr.ht/~qbit/mcchunkie.svg)](https://builds.sr.ht/~qbit/mcchunkie?) -` +[![builds.sr.ht status](https://builds.sr.ht/~qbit/mcchunkie.svg)](https://builds.sr.ht/~qbit/mcchunkie?)` func main() { var username, shortName, password, userID, accessToken, server, db, avatar, botOwner string @@ -66,7 +65,7 @@ func main() { if doc { fmt.Println(header) - fmt.Println("|Plugin Name|Match|Description|") + fmt.Println("\n|Plugin Name|Match|Description|") fmt.Println("|----|---|---|") for _, p := range plugins.Plugs { fmt.Printf("|%s|`%s`|%s|\n", p.Name(), p.Re(), p.Descr()) diff --git a/pass_reader.go b/pass_reader.go index bda7996..8d8f70c 100644 --- a/pass_reader.go +++ b/pass_reader.go @@ -6,6 +6,7 @@ import ( "golang.org/x/crypto/ssh/terminal" ) +//noinspection GoUnresolvedReference func prompt(p string) (string, error) { oldState, err := terminal.MakeRaw(0) if err != nil { diff --git a/plugins/plugins.go b/plugins/plugins.go index f4492a6..288a59e 100644 --- a/plugins/plugins.go +++ b/plugins/plugins.go @@ -123,7 +123,10 @@ func SendText(c *gomatrix.Client, roomID, message string) error { return err } - c.SendText(roomID, message) + _, err = c.SendText(roomID, message) + if err != nil { + return err + } _, err = c.UserTyping(roomID, false, 0) if err != nil { @@ -140,7 +143,10 @@ func SendHTML(c *gomatrix.Client, roomID, message string) error { return err } - c.SendMessageEvent(roomID, "m.room.message", gomatrix.GetHTMLMessage("m.text", message)) + _, err = c.SendMessageEvent(roomID, "m.room.message", gomatrix.GetHTMLMessage("m.text", message)) + if err != nil { + return err + } _, err = c.UserTyping(roomID, false, 0) if err != nil { @@ -159,7 +165,10 @@ func SendMDNotice(c *gomatrix.Client, roomID, message string) error { md := []byte(message) html := markdown.ToHTML(md, nil, nil) - c.SendMessageEvent(roomID, "m.room.message", gomatrix.GetHTMLMessage("m.notice", string(html))) + _, err = c.SendMessageEvent(roomID, "m.room.message", gomatrix.GetHTMLMessage("m.notice", string(html))) + if err != nil { + return err + } _, err = c.UserTyping(roomID, false, 0) if err != nil { @@ -172,8 +181,7 @@ func SendMDNotice(c *gomatrix.Client, roomID, message string) error { func SendMD(c *gomatrix.Client, roomID, message string) error { md := []byte(message) html := markdown.ToHTML(md, nil, nil) - SendHTML(c, roomID, string(html)) - return nil + return SendHTML(c, roomID, string(html)) } // SendImage takes an image and sends it!. @@ -182,7 +190,7 @@ func SendImage(c *gomatrix.Client, roomID string, img *image.RGBA) error { go func() { defer w.Close() - png.Encode(w, img) + _ = png.Encode(w, img) }() mediaURL, err := c.UploadToContentRepo(r, "image/png", 0) diff --git a/plugins/plugins_test.go b/plugins/plugins_test.go index 38cc6df..fff8504 100644 --- a/plugins/plugins_test.go +++ b/plugins/plugins_test.go @@ -34,7 +34,10 @@ type testResp struct { func TestHTTPRequestDoJSON(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintln(w, `{"test":"success"}`) + _, err := fmt.Fprintln(w, `{"test":"success"}`) + if err != nil { + t.Error(err) + } })) defer ts.Close() diff --git a/plugins/source.go b/plugins/source.go index b3f4de6..76cd756 100644 --- a/plugins/source.go +++ b/plugins/source.go @@ -21,7 +21,7 @@ func (h *Source) Re() string { return `(?i)where is your (source|code)` } -// Match determins if someone is asking about the source code +// Match determines if someone is asking about the source code func (h *Source) Match(user, msg string) bool { re := regexp.MustCompile(h.Re()) return re.MatchString(msg) && ToMe(user, msg) diff --git a/plugins/thanks.go b/plugins/thanks.go index f3913fa..aedd0b1 100644 --- a/plugins/thanks.go +++ b/plugins/thanks.go @@ -23,7 +23,7 @@ func (h *Thanks) Re() string { return `(?i)^thank you|thank you$|^thanks|thanks$|^ty|ty$` } -// Match determins if we are being thanked +// Match determines if we are being thanked func (h *Thanks) Match(user, msg string) bool { re := regexp.MustCompile(h.Re()) return re.MatchString(msg) && ToMe(user, msg) diff --git a/plugins/welcome_back.go b/plugins/welcome_back.go index 50be86c..9bcc396 100644 --- a/plugins/welcome_back.go +++ b/plugins/welcome_back.go @@ -21,7 +21,7 @@ func (h *Wb) Re() string { return `(?i)^welcome back|welcome back$|^wb|wb$` } -// Match determins if we are welcomed back +// Match determines if we are welcomed back func (h *Wb) Match(user, msg string) bool { re := regexp.MustCompile(h.Re()) return re.MatchString(msg) && ToMe(user, msg)