M
M
Miraid2022-01-09 01:59:42
go
Miraid, 2022-01-09 01:59:42

How to make a Telegram bot in Golang that sends similar messages to the same chat?

What is the point, I want to write a telegram bot that forwards previously sent messages to a chat with the same title. that is, when the user writes for example "/search text" the bot must find a message with the word "text" and forward it. I can't figure out how to implement this in go.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2022-01-09
@Spargwy

I can't figure out how to implement this in go.

Can you do it in other languages?
If yes, what exactly is the problem?
Analyze messages in the database and forward those that fit the criteria.

M
Mitch Conner, 2022-01-09
@fruworg

//разделяем предложение на слова по пробелам
arr := strings.Split(m.Text, " ")
//вырезаем первое слово (в нашем случае команду /search)
if arr[0] == "/search"{
msg := strings.TrimPrefix(m.Text, arr[0]+" ")}else{
msg := "Это не поиск!"}

I used this design here , you can see how it is implemented.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question