Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "net/http"
- "strconv"
- "strings"
- "io/ioutil"
- "regexp"
- )
- func sendMessage(userid int, message string) {
- modmsg := strings.Replace(message, " ", "%20", -1)
- _, err := http.Get("https://api.telegram.org/bot" + token + "/sendmessage?&chat_id=" + strconv.Itoa(userid) + "&text=" + modmsg)
- if err != nil {
- fmt.Println("[ERROR]Unable to access API")
- }
- fmt.Printf("[BOT -> %d] %s\n", userid, message)
- }
- func interpret(chatid int, message string) {
- r, _ := regexp.Compile(`^([a-zA-Zа-яёА-ЯЁ0-9 ]*)\/w`)
- if r.MatchString(message) {
- sendMessage(chatid, r.FindStringSubmatch(message)[1] + " - ачивмент анлокед")
- }
- switch message { //This is here for later use if needed.
- case "/start":
- sendMessage(chatid, "Welcome to Telegram ...!")
- case "/sp":
- sendMessage(chatid, "Текст")
- case "/about":
- sendMessage(chatid, "текст2")
- case "/social":
- sendMessage(chatid, "1")
- sendMessage(chatid, "2")
- sendMessage(chatid, "3")
- sendMessage(chatid, "4")
- sendMessage(chatid, "5")
- sendMessage(chatid, "6")
- case "/gs":
- sendMessage(chatid, "12")
- sendMessage(chatid, "13")
- sendMessage(chatid, "14")
- sendMessage(chatid, "15")
- sendMessage(chatid, "16")
- case "/zzz":
- sendMessage(chatid, "17")
- case "/nuke":
- body, err := http.Get("https://api.twitch.tv/kraken/streams/nuke73")
- if err != nil {
- sendMessage(chatid, "Cannot retrieve data of streamer")
- }
- output, _ := ioutil.ReadAll(body.Body)
- sendMessage(chatid, twitchDecode(output))
- default:
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement