-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major update, fix all memory leaks, enhance lib performance, fix log …
…color disabling, remove unwanted codes, bug fixes, fix goroutine flooding, enhance log config, enhance cache config with option to disable completely, add example on cache, Layer 195, v1.4.4
- Loading branch information
1 parent
88dda88
commit 7d05ffe
Showing
7 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package examples | ||
|
||
import ( | ||
"github.com/amarnathcjd/gogram/telegram" | ||
) | ||
|
||
const ( | ||
appID = 6 | ||
appHash = "YOUR_APP_HASH" | ||
botToken = "YOUR_BOT_TOKEN" | ||
) | ||
|
||
func main() { | ||
// create a new client object | ||
client, _ := telegram.NewClient(telegram.ClientConfig{ | ||
AppID: appID, | ||
AppHash: appHash, | ||
LogLevel: telegram.LogInfo, | ||
Cache: telegram.NewCache("cache_file.db", &telegram.CacheConfig{ | ||
MaxSize: 1000, // TODO | ||
LogLevel: telegram.LogInfo, | ||
LogNoColor: true, // disable color in logs | ||
Memory: true, // disable writing to disk | ||
Disabled: false, // to totally disable cache | ||
}), // if left empty, it will use the default cache 'cache.db', with default config | ||
}) | ||
|
||
client.LoginBot(botToken) | ||
|
||
client.On(telegram.OnMessage, func(message *telegram.NewMessage) error { | ||
message.Respond(message) | ||
return nil | ||
}, telegram.FilterPrivate) | ||
|
||
client.On("message:/start", func(message *telegram.NewMessage) error { | ||
message.Reply("Hello, I am a bot!") | ||
return nil | ||
}) | ||
|
||
// lock the main routine | ||
client.Idle() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters