Skip to content

Commit

Permalink
Me function (#57)
Browse files Browse the repository at this point in the history
* Me function

* Improved me function

* updated me function

* Added comments.
  • Loading branch information
PrimalPimmy authored Nov 16, 2020
1 parent ce91f77 commit f15032e
Showing 1 changed file with 12 additions and 0 deletions.
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 @@ -55,6 +56,15 @@ func tweet() {
demux.HandleChan(stream.Messages)

}
//Sends message of whatever the user specifies they are doing after they type this command, then deletes the user's command message.
func me(message *tbot.Message, ID int64) {
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) {
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

0 comments on commit f15032e

Please sign in to comment.