Skip to content

Commit

Permalink
Change all value to pointer receivers
Browse files Browse the repository at this point in the history
  • Loading branch information
Brawl345 committed Oct 10, 2024
1 parent dc27c59 commit bff2ff1
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 20 deletions.
9 changes: 5 additions & 4 deletions handler/feed_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package handler
import (
"bytes"
"errors"
"github.com/Brawl345/rssbot/storage"
"gopkg.in/telebot.v3"
"html"
"log"
"net/url"
"regexp"
"strings"
"sync"
"time"

"github.com/Brawl345/rssbot/storage"
"gopkg.in/telebot.v3"
)

type TemplateData struct {
Expand All @@ -22,7 +23,7 @@ type TemplateData struct {
PostDomain string
}

func (h Handler) OnCheck() {
func (h *Handler) OnCheck() {
var wg sync.WaitGroup
log.Println("===============================/")
abonnements, err := h.DB.Abonnements.GetAll()
Expand Down Expand Up @@ -150,7 +151,7 @@ func processContent(content string, replacements *[]storage.Replacement) string
return processed
}

func (h Handler) sendText(chatId int64, text string, url string) error {
func (h *Handler) sendText(chatId int64, text string, url string) error {
_, err := h.Bot.Send(telebot.ChatID(chatId), text, defaultSendOptions)

var floodError *telebot.FloodError
Expand Down
5 changes: 3 additions & 2 deletions handler/feed_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package handler

import (
"fmt"
"gopkg.in/telebot.v3"
"html"
"log"
"strings"

"gopkg.in/telebot.v3"
)

func (h Handler) OnList(c telebot.Context) error {
func (h *Handler) OnList(c telebot.Context) error {
args := c.Args()

if len(args) > 1 {
Expand Down
5 changes: 3 additions & 2 deletions handler/feed_list_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package handler

import (
"fmt"
"gopkg.in/telebot.v3"
"html"
"log"
"strings"

"gopkg.in/telebot.v3"
)

func (h Handler) OnListAll(c telebot.Context) error {
func (h *Handler) OnListAll(c telebot.Context) error {
if !c.Message().Private() {
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions handler/feed_subscribe.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package handler

import (
"log"

"github.com/mmcdole/gofeed"
"gopkg.in/telebot.v3"
"log"
)

func (h Handler) OnSubscribe(c telebot.Context) error {
func (h *Handler) OnSubscribe(c telebot.Context) error {
args := c.Args()

if len(args) == 0 || len(args) > 2 {
Expand Down
5 changes: 3 additions & 2 deletions handler/feed_unsubscribe.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package handler

import (
"gopkg.in/telebot.v3"
"log"
"strconv"

"gopkg.in/telebot.v3"
)

func (h Handler) OnUnsubscribe(c telebot.Context) error {
func (h *Handler) OnUnsubscribe(c telebot.Context) error {
args := c.Args()

if len(args) == 0 || len(args) > 2 {
Expand Down
5 changes: 3 additions & 2 deletions handler/replacement_add.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package handler

import (
"github.com/go-sql-driver/mysql"
"gopkg.in/telebot.v3"
"log"
"regexp"
"strings"

"github.com/go-sql-driver/mysql"
"gopkg.in/telebot.v3"
)

func (h *Handler) OnAddReplacement(c telebot.Context) error {
Expand Down
5 changes: 3 additions & 2 deletions handler/replacement_delete.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package handler

import (
"gopkg.in/telebot.v3"
"log"
"strconv"

"gopkg.in/telebot.v3"
)

func (h Handler) OnDeleteReplacement(c telebot.Context) error {
func (h *Handler) OnDeleteReplacement(c telebot.Context) error {
args := c.Args()

if len(args) == 0 || len(args) > 1 {
Expand Down
5 changes: 3 additions & 2 deletions handler/replacement_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package handler

import (
"fmt"
"gopkg.in/telebot.v3"
"html"
"log"
"strings"

"gopkg.in/telebot.v3"
)

func (h Handler) OnListReplacements(c telebot.Context) error {
func (h *Handler) OnListReplacements(c telebot.Context) error {
replacements, err := h.DB.Replacements.List()

if !c.Message().Private() {
Expand Down
5 changes: 3 additions & 2 deletions handler/start.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package handler

import (
"gopkg.in/telebot.v3"
"strings"

"gopkg.in/telebot.v3"
)

func (h Handler) OnStart(c telebot.Context) error {
func (h *Handler) OnStart(c telebot.Context) error {
var sb strings.Builder
sb.WriteString("<b>/rss</b> <i>[Chat]</i>: Abonnierte Feeds anzeigen\n")
sb.WriteString("<b>/rss_all</b>: Alle abonnierten Feeds aus jedem Chat anzeigen\n")
Expand Down

0 comments on commit bff2ff1

Please sign in to comment.