summaryrefslogtreecommitdiffstats
path: root/bridge/helper.go
blob: 7669ad57115a5e0c43692bf02b47bcaab12ec86d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package bridge

import (
	"strings"
)

func tableformatter(nicks []string, nicksPerRow int, continued bool) string {
	result := "|IRC users"
	if continued {
		result = "|(continued)"
	}
	for i := 0; i < 2; i++ {
		for j := 1; j <= nicksPerRow && j <= len(nicks); j++ {
			if i == 0 {
				result += "|"
			} else {
				result += ":-|"
			}
		}
		result += "\r\n|"
	}
	result += nicks[0] + "|"
	for i := 1; i < len(nicks); i++ {
		if i%nicksPerRow == 0 {
			result += "\r\n|" + nicks[i] + "|"
		} else {
			result += nicks[i] + "|"
		}
	}
	return result
}

func plainformatter(nicks []string, nicksPerRow int) string {
	return strings.Join(nicks, ", ") + " currently on IRC"
}

func IsMarkup(message string) bool {
	switch message[0] {
	case '|':
		fallthrough
	case '#':
		fallthrough
	case '_':
		fallthrough
	case '*':
		fallthrough
	case '~':
		fallthrough
	case '-':
		fallthrough
	case ':':
		fallthrough
	case '>':
		fallthrough
	case '=':
		return true
	}
	return false
}