aboutsummaryrefslogtreecommitdiff
path: root/go-src/utils
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-07-21 11:04:46 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-07-21 11:04:46 +0300
commit12558447c73da90f63276143f4d6a8796ec2fe7b (patch)
treefad42fa04b56d497d7251bf4270f7c427ba8feea /go-src/utils
parent7457f7af8effa21ecf328058475e944e46075670 (diff)
downloadctfc-12558447c73da90f63276143f4d6a8796ec2fe7b.tar
ctfc-12558447c73da90f63276143f4d6a8796ec2fe7b.tar.gz
ctfc-12558447c73da90f63276143f4d6a8796ec2fe7b.zip
Implemented a very hardcoded way for chat message pagination and real time updating
Diffstat (limited to 'go-src/utils')
-rw-r--r--go-src/utils/utils.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/go-src/utils/utils.go b/go-src/utils/utils.go
index 754c7ed..c1bd8a4 100644
--- a/go-src/utils/utils.go
+++ b/go-src/utils/utils.go
@@ -1,6 +1,8 @@
package utils
-import "os"
+import (
+ "os"
+)
// Repeats a rune given amount of times and returns the result as a string
func RepeatRune(r rune, times int) (result string) {
@@ -31,3 +33,11 @@ func AppendToFile(path string, value string) {
allChatsFile.WriteString(value)
allChatsFile.Close()
}
+
+func TotalPages(maxSize int, messageAmount int) int {
+ return messageAmount / maxSize
+}
+
+func Paginate(page int, maxSize int, messages ...string) []string {
+ return messages[len(messages)-maxSize*page : len(messages)-maxSize*(page-1)]
+}