简体   繁体   English

如何将一条消息中的数据发送到电报机器人?

[英]How to send data in one message to a telegram bot?

Now I'm making a method, after which the data is successfully sent from the telegram bot to the user.现在我正在制作一个方法,之后数据成功地从电报机器人发送给用户。 Now I have made this option.现在我做出了这个选择。 However, the problem is that all data is sent separately.但是,问题是所有数据都是单独发送的。

And if we assume we have 20 books in the matrix, we get 21 messages with customer data.如果我们假设矩阵中有 20 本书,我们会收到 21 条包含客户数据的消息。

How can I make everything is sent in one message?如何使所有内容都在一条消息中发送?

private void Form_DataAddAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
        {
            SAPbouiCOM.EditText oEdit_Customer = (SAPbouiCOM.EditText)this.GetItem("4").Specific;
            SAPbouiCOM.EditText oEdit_Name = (SAPbouiCOM.EditText)this.GetItem("54").Specific;
            SAPbouiCOM.EditText oEdit_PostingDate = (SAPbouiCOM.EditText)this.GetItem("10").Specific;
            SAPbouiCOM.EditText oEdit_Total = (SAPbouiCOM.EditText)this.GetItem("29").Specific;

            SendTextMessage(($"Return of the book!\n\nCustomer: {oEdit_Customer.Value}\nCustomer's name: {oEdit_Name.Value}\nReturn date: {oEdit_PostingDate.Value}\nTotal: {oEdit_Total.Value} "));
           
 for (int j = 1; j < Matrix0.RowCount-1; j++)
            {
                SAPbouiCOM.EditText cell_Description = (SAPbouiCOM.EditText)Matrix0.Columns.Item("1").Cells.Item(j).Specific;
                SAPbouiCOM.EditText cell_Quantity = (SAPbouiCOM.EditText)Matrix0.Columns.Item("U_inUseQuantity").Cells.Item(j).Specific;

                SendTextMessage(($"Book: {cell_Description.Value}\nQuantity: {cell_Quantity.Value}"));
            }
        }

Not tested this code but should work.未测试此代码,但应该可以工作。 Store your "messages" in a string variable add the strings you are currently sending to it.将您的“消息”存储在字符串变量中,添加您当前发送给它的字符串。 You can then send the string "sendText" after the loop然后您可以在循环之后发送字符串“sendText”

    string sendText = "";
    for (int j = 1; j < Matrix0.RowCount-1; j++)
    {
        SAPbouiCOM.EditText cell_Description = (SAPbouiCOM.EditText)Matrix0.Columns.Item("1").Cells.Item(j).Specific;
        SAPbouiCOM.EditText cell_Quantity = (SAPbouiCOM.EditText)Matrix0.Columns.Item("U_inUseQuantity").Cells.Item(j).Specific;

        sendText += $"Book: {cell_Description.Value}\nQuantity: {cell_Quantity.Value}\n";
    }
    SendTextMessage(sendText);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM