-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontains.go
More file actions
31 lines (26 loc) · 809 Bytes
/
contains.go
File metadata and controls
31 lines (26 loc) · 809 Bytes
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
package main
import (
"regexp"
tl "github.com/goTelegramBot/gogram"
"github.com/goTelegramBot/gogram/types"
)
func contains(b tl.Bot,m *types.Message){
var message string
if m.ReplyToMessage != nil{
message = m.ReplyToMessage.Text
}else{
b.SendMessage(m.Chat.Id,"_Reply to any message with_ /contains <keyword> _to match texts_",&tl.Options{ParseMode:"Markdown"})
return
}
args := m.Args()
if len(args) < 1 {
b.SendMessage(m.Chat.Id,"*Specify some keyword to match text*",&tl.Options{ParseMode:"Markdown"})
return
}
rx := regexp.MustCompile(args[1])
if rx.MatchString(message){
b.SendMessage(m.Chat.Id,"Contains",&tl.Options{ParseMode:"Markdown"})
}else{
b.SendMessage(m.Chat.Id, "*Message dont match*",&tl.Options{ParseMode:"Markdown"})
}
}