コード例 #1
0
        public async Task Invoke(MessageRequest request)
        {
            var message = MessageTemplate.Create()
                          .SetText($"Nice to meet you, {request.Text}! Let's start studying");

            await SendMessageAsync(message);

            await Redirect(GetCommandName <MenuCommand>());
        }
コード例 #2
0
        public async Task Invoke()
        {
            await TelegramBot.SetChatStateAsync(new ChatState
            {
                WaitingFor = GetCommandName <NameCommand>()
            });

            await SendMessageAsync(
                MessageTemplate.Create()
                .SetText("Hello! What's your name?"));
        }
コード例 #3
0
        public async Task Invoke(QueryRequest request)
        {
            var replyMarkup = new InlineKeyboardMarkup()
                              .AddRow(new InlineKeyboardButton("Lab 2", callbackData: $"{GetCommandName<FileCommand>()}:fileId=pvms_lab2.pdf"));

            await EditMessageAsync(request.MessageId, MessageTemplate.Create()
                                   .SetText("Choose your lab:")
                                   .SetMarkup(replyMarkup));

            await AnswerCallbackQueryAsync(request.QueryId);
        }
コード例 #4
0
        public async Task Invoke(QueryRequest request)
        {
            await using var document = new FileStream(
                            $@"wwwroot\Labs\{request.Query.GetQueryParam("fileId")}",
                            FileMode.Open,
                            FileAccess.Read);

            var message = MessageTemplate.Create()
                          .SetText("Have fun");

            await SendMessageAsync(message);

            await AnswerCallbackQueryAsync(request.QueryId);

            await SendFileAsync(document);
        }
コード例 #5
0
ファイル: NewMessageWindow.xaml.cs プロジェクト: fhoner/Kasse
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            int duration;
            int limitmins;

            try
            {
                if (!int.TryParse(txtDuration.Text, out duration))
                    throw new Exception("Die angegebene Mindestanzeigedauer ist ungültig.");
                if (duration < 0 || duration > 60)
                    throw new Exception("Die Mindestanzeigedauer muss zwischen 0 und 60 Sekunden liegen.");
                if (txtMessage.Text.Length < 1)
                    throw new Exception("Die Nachricht darf nicht leer sein.");
                if (!int.TryParse(txtDateLimitMinutes.Text, out limitmins))
                    throw new Exception("Der Wert für das Zeitlimit ist ungültig.");

                List<User> users = (from u in selectedUsers where u.IsSelected == true select u.User as User).ToList();
                if (users.Count < 1)
                    throw new Exception("Es wurden keine Benutzer ausgewählt.");

                MessageTemplate tpl = new MessageTemplate();
                tpl.Content = txtMessage.Text;
                tpl.Duration = duration;
                tpl.ForceLogout = chbxForceLogoff.IsChecked == true ? true : false;
                if (limitmins > 0) tpl.DateLimit = DateTime.Now.AddMinutes(limitmins);

                foreach (User u in users) tpl.Recipients.Add(u);

                messages.Add(tpl.Create());
                VisualMessageBox.Show("Die Nachricht wurde gespeichert.", "Nachricht erstellt");

                txtMessage.Text = "";
                foreach (UserSelection s in selectedUsers) s.IsSelected = false;
            }
            catch (Exception ex)
            {
                VisualMessageBox.Show(ex.Message, "Fehler");
            }            
        }
コード例 #6
0
        public async Task Invoke(MessageRequest request)
        {
            var subject = SubjectsResolver.ResolveSubject(request.Text);
            var type    = SubjectsResolver.ResolveType(request.Text);
            var number  = SubjectsResolver.ResolveNumber(request.Text);

            if (new[] { subject, type, number?.ToString() }.Any(x => x == null))
            {
                await SendMessageAsync(MessageTemplate.Create()
                                       .SetText("What? 🧐"));

                return;
            }

            var fileName = $"{subject}_{type}{number}.pdf";

            await using var document = new FileStream(
                            $@"wwwroot\Labs\{fileName}",
                            FileMode.Open,
                            FileAccess.Read);

            await SendFileAsync(document);
        }
コード例 #7
0
 public async Task Invoke()
 {
     await SendMessageAsync(MessageTemplate.Create()
                            .SetText("Something went wrong =("));
 }
コード例 #8
0
 public async Task Invoke()
 {
     await SendMessageAsync(MessageTemplate.Create().SetText("Undefined command"));
 }