website icon indicating copy to clipboard operation
website copied to clipboard

Updated documentation for chat-members plugin, adding new sections about filters

Open rayz1065 opened this issue 11 months ago • 6 comments

This pull request adds documentation for chat member filters in the chat-members plugin section.

https://github.com/grammyjs/chat-members/pull/10

Let me know if the paragraph structure or anything else could be improved.

rayz1065 avatar Jan 23 '25 14:01 rayz1065

🚀 Deployed on https://6908b6b55618fb20d5501152--grammy.netlify.app

github-actions[bot] avatar Jan 23 '25 14:01 github-actions[bot]

@roziscoding anything else?

KnorpelSenf avatar Jan 30 '25 11:01 KnorpelSenf

@roziscoding anything else?

not at all, this looks great! thanks @rayz1065!

roziscoding avatar Jan 30 '25 11:01 roziscoding

add a few lines to the existing code example and contrast it with the code

Were you thinking something like:

In contrast, filtering for users joining a group/supergroup without this plugin would require the following code:

// filter for users joining the group without the plugin
bot
  .chatType(["group", "supergroup"])
  .on("chat_member")
  .filter(
    (ctx) => {
      const { old_chat_member: oldMember, new_chat_member: newMember } =
        ctx.chatMember;
      return (
        (["kicked", "left"].includes(oldMember.status) ||
          (oldMember.status === "restricted" && !oldMember.is_member)) &&
        (["administrator", "creator", "member"].includes(newMember.status) ||
          (newMember.status === "restricted" && newMember.is_member))
      );
    },
    (ctx) => {
      ctx.chatMember.new_chat_member.status; // type is not narrowed :(
    }
  );

Right after the code-group showing the various filters?

rayz1065 avatar Feb 14 '25 10:02 rayz1065

Yes, except that I would include it in the existing code group and add comments

// WITHOUT this plugin:
complexCode
// WITH this plugin:
easyCode

but that's just something to try out, I am not saying that I'm sure it's better

KnorpelSenf avatar Feb 14 '25 11:02 KnorpelSenf

Yes, except that I would include it in the existing code group and add comments

I included that snippet within the code group, I think it's a nice addition as it makes for some nice contrast, let me know if it should be changed in some way.

Thank you @rojvv for the review!

Is there anything else that should be changed before this PQ is ready for translation?

rayz1065 avatar Feb 19 '25 11:02 rayz1065

@LWJerri @niusia-ua do you think it is better to translate the SVG file, too?

KnorpelSenf avatar Apr 16 '25 07:04 KnorpelSenf

@KnorpelSenf No, I don't think so. In that image, terms are used as actual values in code. They are not something to translate.

niusia-ua avatar Apr 16 '25 07:04 niusia-ua

That's a great point. Let's leave it like it is.

KnorpelSenf avatar Apr 16 '25 07:04 KnorpelSenf