Skip to content

Commit 1a3e995

Browse files
committed
QuickSend method added to bot
1 parent 1cede9c commit 1a3e995

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ func main() {
8585
}
8686
```
8787

88+
For quickly send text message you can use BotAPI method `QuickSend(chatID, "your message")`
89+
8890
If you need, you may generate a self signed certficate, as this requires HTTPS / TLS. The above example tells Telegram that this is your certificate and that it should be trusted, even though it is not properly signed.
8991

9092
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3560 -subj "//O=Org\CN=Test" -nodes

bot.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ func (bot *BotAPI) Send(c Chattable) (Message, error) {
220220
}
221221
}
222222

223+
// QuickSend will send message to selected chat
224+
func (bot *BotAPI) QuickSend(chatID int, message string) (Message, error) {
225+
msg := NewMessage(chatID, message)
226+
return bot.Send(msg)
227+
}
228+
223229
func (bot *BotAPI) debugLog(context string, v url.Values, message interface{}) {
224230
if bot.Debug {
225231
log.Printf("%s req : %+v\n", context, v)

bot_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ func TestSendChatConfig(t *testing.T) {
342342
}
343343
}
344344

345+
func TestQuickSend(t *testing.T) {
346+
bot, _ := getBot(t)
347+
348+
_, err := bot.QuickSend(ChatID, "test message")
349+
350+
if err != nil {
351+
t.Fail()
352+
}
353+
}
354+
345355
func TestGetUserProfilePhotos(t *testing.T) {
346356
bot, _ := getBot(t)
347357

0 commit comments

Comments
 (0)