File tree 6 files changed +93
-3
lines changed
6 files changed +93
-3
lines changed Original file line number Diff line number Diff line change 1
1
# clean-architecture-telegram-bot
2
2
3
- A sample for creating telegram bots in Golang with clean architecture
3
+ A sample project for creating telegram bots in Golang with clean architecture.
4
+
5
+ ## /cmd
6
+
7
+ Main functionality for the bot.
Original file line number Diff line number Diff line change
1
+ package cmd
2
+
3
+ import (
4
+ "os"
5
+
6
+ "github.com/urfave/cli/v2"
7
+ )
8
+
9
+ func Run () error {
10
+ app := cli.App {
11
+ Name : "Sample-telegram-bot" ,
12
+ Usage : "A sample project for creating telegram bots in Golang with clean architecture" ,
13
+ UsageText : "Sample-telegram-bot [command] serve (s) [command option] debug (d)" ,
14
+ Version : "0.1" ,
15
+ Commands : []* cli.Command {
16
+ serveCMD ,
17
+ },
18
+ }
19
+
20
+ return app .Run (os .Args )
21
+ }
Original file line number Diff line number Diff line change
1
+ package cmd
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/urfave/cli/v2"
7
+ )
8
+
9
+ var (
10
+ serveCMD = & cli.Command {
11
+ Name : "serve" ,
12
+ Aliases : []string {"s" },
13
+ Usage : "Serving telegram bot" ,
14
+ Action : serve ,
15
+ Subcommands : []* cli.Command {
16
+ debugCMD ,
17
+ },
18
+ }
19
+
20
+ debugCMD = & cli.Command {
21
+ Name : "debug" ,
22
+ Aliases : []string {"d" },
23
+ Usage : "Turn on debug mode" ,
24
+ After : serve ,
25
+ Action : debug ,
26
+ }
27
+
28
+ debugMode = false
29
+ )
30
+
31
+ func serve (c * cli.Context ) error {
32
+ fmt .Printf ("Debug mod is: %t\n " , debugMode )
33
+ fmt .Println ("clean-architecture-telegram-bot" )
34
+
35
+ return nil
36
+ }
37
+
38
+ func debug (c * cli.Context ) error {
39
+ fmt .Println ("Debug mode is on" )
40
+ debugMode = true
41
+
42
+ return nil
43
+ }
Original file line number Diff line number Diff line change 1
1
module github.com/barahouei/clean-architecture-telegram-bot
2
2
3
3
go 1.20
4
+
5
+ require github.com/urfave/cli/v2 v2.25.7
6
+
7
+ require (
8
+ github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
9
+ github.com/russross/blackfriday/v2 v2.1.0 // indirect
10
+ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
11
+ )
Original file line number Diff line number Diff line change
1
+ github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w =
2
+ github.com/cpuguy83/go-md2man/v2 v2.0.2 /go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o =
3
+ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk =
4
+ github.com/russross/blackfriday/v2 v2.1.0 /go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM =
5
+ github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs =
6
+ github.com/urfave/cli/v2 v2.25.7 /go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ =
7
+ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU =
8
+ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 /go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8 =
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
- import "fmt"
3
+ import (
4
+ "log"
5
+
6
+ "github.com/barahouei/clean-architecture-telegram-bot/cmd"
7
+ )
4
8
5
9
func main () {
6
- fmt .Println ("clean-architecture-telegram-bot" )
10
+ if err := cmd .Run (); err != nil {
11
+ log .Fatal (err )
12
+ }
7
13
}
You can’t perform that action at this time.
0 commit comments