weixin_39970166
2020-12-09 13:19 阅读 0

cache replyto chat

so no need to replyto every msg

该提问来源于开源项目:blueset/efb-telegram-master

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

10条回答 默认 最新

  • weixin_39630999 weixin_39630999 2020-12-09 13:19

    Hi, can you further elaborate on what this PR changes? It'd be great if you can update the README file if this PR involves changes in user interaction.

    Thanks!

    点赞 评论 复制链接分享
  • weixin_39970166 weixin_39970166 2020-12-09 13:19

    usually, we need to reply to a message in a private or group with multi slaves. so the etm can know where to send. this pr cache the destination when you reply to a message. then, if you send a message without replied infomation, it will use the last cached destination.

    点赞 评论 复制链接分享
  • weixin_39970166 weixin_39970166 2020-12-09 13:19

    At the beginning, I had thought about this question. My solution is below, but not finished.(I'm not good at python) Set a timer to delete the cache after 10 minites or half an hour. Or set a timestamp when replied to message. Check if it has expired. This will cover most of the situations. Because if it is not a temporary chat, we will link it to a single group.

    点赞 评论 复制链接分享
  • weixin_39586825 weixin_39586825 2020-12-09 13:19

    Agree with . I don't think it's a good idea to cache replyto chat, at least not in a way with no explicit notification about which chat the user is replying to. Actually, I think the approach proposed by that expires a cache after a short period of time, 'cauze it may make user even more confusing. I think we should keep the status consistent without user's operation.

    If we really need this feature to reply to a chat instantly with no need to create a new group to link to, maybe we need a new commands to check the chat that the user want to reply to.

    In this case, we could cache the last replied chat as this pr does, and users could check the chat they are to reply by typing something like /replyto. This may help solve the problem that

    After a longer period of time, the user might just forget who they last replied

    点赞 评论 复制链接分享
  • weixin_39630999 weixin_39630999 2020-12-09 13:19

    Even with a check command like /replyto, users would simply forget to use that to check recipients, as they would forget to do quote-reply for messages.

    If we would take the timeout version of the "cached reply-to" strategy proposed here by , it's probably better to notify the user about what ETM is going to do on this chat every time it starts to use/change the cache, like:

    All messages sent here without recipient indication in the next {timeout} minutes will be sent to "{chat.long_name}" from "{chat.module_name}" until you indicate a new recipient.

    However, I would still consider this as an arguable feature, and would prioritize more on other existing proposals, unit tests and stable version releases. As usual, if there are better implementations, I'll be more than grateful to give the PR a review.

    点赞 评论 复制链接分享
  • weixin_39970166 weixin_39970166 2020-12-09 13:19

    How about this.

    
    In a chat thread directly with bot:                               Sent to   |     
    
    +--------------------------------------------------------------+            |                   
    |                                                              |            |                   
    | ETM Bot                                                      |            |                   
    | +-----------------------------+                              |            |                   
    | | Chat A:                     |                              |            |                   
    | | Lorem ipsum dolor sit amet. |                              |            |                   
    | +-----------------------------+                              |            |                   
    |    ^                                                     You |            |                   
    |    |    (quote-reply to)    +------------------------------+ |            |                   
    |    +------------------------| Consectetur adipiscing elit. | |  Chat A    |       cache[bot] = A            
    |                             +------------------------------+ |            |                   
    | ETM Bot                                                      |            |                   
    | +--------------------------------+                           |            |                   
    | | Chat A:                        |                           |            |                   
    | | Nullam hendrerit ullamcorper.  |                           |            |                   
    | +--------------------------------+                           |            |                   
    |                                                          You |            |                   
    |                                   +------------------------+ |            |                   
    |                                   | Finibus, etiam ut sem. | |  Chat A    |       reply to cache[bot] (A)           
    |                                   +------------------------+ |            |                   
    | ETM Bot                                                      |            |                   
    | +-------------------------------+                            |            |                   
    | | Chat A:                       |                            |            |                   
    | | Vitae augue feugiat eleifend. |                            |            |                   
    | +-------------------------------+                            |            |                   
    |                                                              |            |                   
    |                                                              |            |                   
    .                                                              .            |                   
    .                     < Few hours later >                      .            |       cache[bot] expire after an hour           
    .                                                              .            |                   
    |                                                              |            |                   
    |                                                              |            |                   
    |                                                              |            |                   
    |  ETM Bot                                                     |            |                   
    |  +---------------------------+                               |            |                   
    |  | Chat B:                   |                               |            |                   
    |  | Nunc vestibulum interdum! |                               |            |                   
    |  +---------------------------+--------+                      |            |                   
    |  | Chat C:                            |                      |            |                   
    |  | Non scelerisque quam venenatis in. |                      |            |                   
    |  +-----------------------------------++                      |            |                   
    |  | Chat C:                           |                       |            |                   
    |  | Nunc hendrerit nunc eu justo      |                       |            |                   
    |  | auctor, at porttitor metus orane. |                       |            |                   
    |  +-------------------------------+---+                       |            |                   
    |  | Chat C:                       |                           |            |                   
    |  | Etiam pulvinar neque sit amet |                           |            |                   
    |  | libero eleifend tincidunt.    |                           |            |                   
    |  +-------------------------------+                           |            |                   
    |                                                          You |            |                   
    |                                    +-----------------------+ |            |                   
    |                                    | [Something intended   | |    None    |       cache[bot] is None, so report an error MS01.            
    |                                    | to reply to Chat C.]  | |            |                   
    |                                    +-----------------------+ |            |                   
    | ETM Bot                                                      |            |                   
    | +--------------------------------------------+               |            |                   
    | | bot:                                       |               |            |                   
    | | Error: No recipient specified.             |               |            |                   
    | | Please reply to a previous message. (MS01) |               |            |                   
    | +--------------------------------------------+               |            |                      
    |                                                              |            |      
    |                                                              |            |      
    |                                                              |            |      
    |    ^                                                     You |            |                   
    |    |    (quote-reply to C)  +------------------------------+ |            |                   
    |    +------------------------| Consectetur adipiscing elit. | |  Chat C    |       cache[bot] = C         
    |                             +------------------------------+ |            |                    
    | ETM Bot                                                      |            |                   
    | +--------------------------------+                           |            |                   
    | | Chat C:                        |                           |            |                   
    | | Nullam hendrerit ullamcorper.  |                           |            |                   
    | +--------------------------------+                           |            |                   
    |                                                          You |            |                   
    |                                   +------------------------+ |            |                   
    |                                   | Finibus, etiam ut sem. | |  Chat C    |       reply to cache[bot] (C)           
    |                                   +------------------------+ |            |                   
    | ETM Bot                                                      |            |                   
    | +-------------------------------+                            |            |                   
    | | Chat C:                       |                            |            |                   
    | | Vitae augue feugiat eleifend. |                            |            |                   
    | +-------------------------------+                            |            |                   
    |                                                              |            |                    
    | ETM Bot                                                      |            |                   
    | +-------------------------------+                            |            |                   
    | | Chat B:                       |                            |            |        cache[bot] != B, remove cache[bot]       
    | | Vitae augue feugiat eleifend. |                            |            |                   
    | +-------------------------------+                            |            |                     
    |                                                          You |            |                   
    |                                    +-----------------------+ |            |                   
    |                                    | [Something intended   | |    None    |       cache[bot] is None, so report an error MS01.            
    |                                    | to reply to Chat C.]  | |            |                   
    |                                    +-----------------------+ |            |                   
    | ETM Bot                                                      |            |                   
    | +--------------------------------------------+               |            |                   
    | | bot:                                       |               |            |                   
    | | Error: No recipient specified.             |               |            |                   
    | | Please reply to a previous message. (MS01) |               |            |                   
    | +--------------------------------------------+               |            |                
    |                                                              |            |                      
    +--------------------------------------------------------------+            |                   
    

    cache expired after an hour. if chatting with C, then B send a message. Remove the cache.

    The original intention of this pr is to solve the temporary chat group that maybe not used after hours or one day. It's not for long term situations.

    点赞 评论 复制链接分享
  • weixin_39630999 weixin_39630999 2020-12-09 13:19

    This looks like a better strategy so far. Does your current code work like that?

    点赞 评论 复制链接分享
  • weixin_39970166 weixin_39970166 2020-12-09 13:19

    Yes. It worked fine for me. Maybe using a configuration to set the expire time is better way.

    Eana Hufwe 于2019年9月14日周六 下午12:23写道:

    This looks like a better strategy so far. Does your current code work like that?

    — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/blueset/efb-telegram-master/pull/69?email_source=notifications&email_token=AASWXYWUDOOC4GDP4COMKLLQJRRMNA5CNFSM4ISOUHN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6WT6TY#issuecomment-531447631, or mute the thread https://github.com/notifications/unsubscribe-auth/AASWXYR6R4QQ7E73S2V34KTQJRRMNANCNFSM4ISOUHNQ .

    点赞 评论 复制链接分享
  • weixin_39970166 weixin_39970166 2020-12-09 13:19

    I have no better practice. So I just take all your advice except https://github.com/blueset/efb-telegram-master/pull/69#discussion_r324426834 Please review again.

    点赞 评论 复制链接分享
  • weixin_39630999 weixin_39630999 2020-12-09 13:19

    Thanks for the effort! I'll merge this now.

    点赞 评论 复制链接分享

相关推荐