Inheritance: System.EventArgs
Esempio n. 1
0
        protected virtual void OnUpdatesReceived(UpdateInfo[] updates)
        {
            var args = new TelegramUpdateEventArgs(updates);

            if (UpdatesReceived != null)
            {
                UpdatesReceived(this, args);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Called when updates received.
        /// </summary>
        /// <param name="updates">The updates</param>
        protected virtual void OnUpdatesReceived(UpdateInfo[] updates)
        {
            TelegramUpdateEventArgs args = new TelegramUpdateEventArgs(updates);

            UpdatesReceived?.Invoke(this, args);
        }
        public static void telegramUpdateReceived(object sender, TelegramUpdateEventArgs e)
        {
            foreach (var update in e.Updates) {
                // DebugWrite (update.Message.From.FirstName + " [" + update.Message.From.Id + "]" + ": ");
                // DebugWriteLine (update.Message.Text);
                // var keyboard = new ReplyKeyboardMarkup ();
                // keyboard.Keyboard = new string[][] { new string[] {"/list"},
                //								        new string[] {"b"} };

                if (update.Message.Text == null) {
                    continue;
                }

                var msg = update.Message.Text.Replace ("-", "").ToLower ();

                StLog.DebugWriteLine ("Message: " + msg, "telegramUpdateReceived(object sender, TelegramUpdateEventArgs e)");

                if (AwaitedAnswers.ContainsKey (update.Message.From.Id)) {
                    var lastCommand = AwaitedAnswers [update.Message.From.Id];
                    if (msg == BotCommands.Cancel) {
                        AwaitedAnswers.Remove (update.Message.From.Id);
                        SendMessage (update.Message.From.Id, "Okay, der Befehl " + lastCommand + " wird abgebrochen.");
                    } else if (lastCommand == BotCommands.RegisterFor) {
                        aw_registerfor (update, msg);
                    } else if (lastCommand == BotCommands.RegisterNew) {
                        aw_registernew (update, update.Message.Text);
                    } else if (lastCommand == BotCommands.UnRegisterFor) {
                        aw_unregisterfor (update, msg);
                    }
                } else {

                    if (msg == BotCommands.Start) {
                        aw_start (update);
                    } else if (msg == BotCommands.RegisterNew) {
                        aw_registernew (update);
                    } else if (msg == BotCommands.RegisterFor) {
                        aw_registerfor (update);
                    } else if (msg == BotCommands.UnRegisterFor) {
                        aw_unregisterfor (update);
                    } else if (msg == BotCommands.List) {
                        aw_list (update);
                    }
                    else {
                        var antwort = Antworten.Get (msg);
                        if (antwort != null) {
                            antwort += "\nUnbekannter Befehl: " + msg;
                            SendMessage (update.Message.From.Id, antwort);
                        } else {
                            SendMessage (update.Message.From.Id, "Unbekannter Befehl: " + msg);
                        }
                    }
                }
            }
        }