Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Me function #57

Merged
merged 5 commits into from
Nov 16, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions telegram-bot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/rand"
"os"
"strconv"
"strings"
"time"

"github.com/anaskhan96/soup"
Expand Down Expand Up @@ -56,6 +57,15 @@ func tweet() {

}

func me(message *tbot.Message, ID int64) {
PrimalPimmy marked this conversation as resolved.
Show resolved Hide resolved
user := message.From.UserName
s := strings.SplitN(message.Text, " ", 2)
if len(s) == 2 {
bot.Send(tbot.NewMessage(ID, "* @"+user+" "+s[1]+" *"))
bot.DeleteMessage(tbot.NewDeleteMessage(ID, message.MessageID))
}
}

//scraping xkcd strip URL from its website with the help of a random generated integer and then sending it as a photo using NewPhotoShare Telegram API method.
func xkcd(ID int64) {
rand.Seed(time.Now().UnixNano())
Expand Down Expand Up @@ -252,6 +262,8 @@ func main() {
fetchnote(ID, update.Message.Text, *client)
case "paste":
paste(ID, update.Message)
case "me":
me(update.Message, ID)
default:
{
msg, err := bot.Send(tbot.NewMessage(ID, "I don't know this command"))
Expand Down