Esempio n. 1
0
        private static async Task Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Trace.Listeners.Add(new ConsoleListener());
            Trace.WriteLine("Starting");
            Bot      = new TelegramBotClient(args[0]);
            Telegram = new TelegramWrapper(Bot);
            my       = await Bot.GetMeAsync();

            Trace.WriteLine("Bot ready");
            Bot.OnReceiveError        += (s, e) => Trace.TraceError($"ReceiveError {e.ApiRequestException}");
            Bot.OnReceiveGeneralError += (s, e) => Trace.TraceError($"ReceiveGeneralError {e.Exception}");
            Bot.OnMessage             += (s, e) => _ = SafeDoTask(OnMessage, e.Message);
            Bot.OnInlineQuery         += (s, e) => _ = SafeDoTask(OnInlineQuery, e.InlineQuery);
            Bot.OnCallbackQuery       += (s, e) => _ = SafeDoTask(OnCallbackQuery, e.CallbackQuery);
            await Bot.SetMyCommandsAsync(new[] {
                new BotCommand {
                    Command = "/start", Description = "Démarrer une partie"
                },
                new BotCommand {
                    Command = "/b", Description = "Relancer d'un montant de votre choix"
                },
            });

            Bot.StartReceiving();
            for (; ;)
            {
                var command = Console.ReadLine()?.ToLower();
                Trace.WriteLine("SysRequest: " + command);
                if (command == "exit")
                {
                    break;
                }
            }
            Trace.WriteLine("Exiting");
        }
Esempio n. 2
0
        //private Player FindPlayer(Message msg) => FindPlayer(msg.From);

        public Game(TelegramWrapper telegram, Chat chat)
        {
            Telegram = telegram;
            Chat     = chat;
            ChatId   = chat.Id;
        }