]> git.jsancho.org Git - midgaard_bot.git/blob - midgaard_bot.go
a11ab8af639d019d6993ebaf2d20e44663356e1d
[midgaard_bot.git] / midgaard_bot.go
1 /*
2 midgaard_bot, a Telegram bot which sets a bridge to Midgaard Merc MUD
3 Copyright (C) 2017 by Javier Sancho Fernandez <jsf at jsancho dot org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 package main
20
21 import (
22         "context"
23         "log"
24
25         "github.com/jessevdk/go-flags"
26 )
27
28 var config struct {
29         Token string `short:"t" long:"token" description:"Telegram API Token" required:"true"`
30 }
31
32 func main() {
33         _, err := flags.Parse(&config)
34         if err != nil {
35                 log.Panic(err)
36         }
37
38         ctx, cancel := context.WithCancel(context.Background())
39         defer cancel()
40
41         err = initSessions(ctx)
42         if err != nil {
43                 log.Panic(err)
44         }
45
46         err = initTelegramWorkers(config.Token, ctx)
47         if err != nil {
48                 log.Panic(err)
49         }
50
51         for {
52                 select {
53                 case <-ctx.Done():
54                         break
55                 }
56         }
57 }