-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from MoC-OSS/feature/UABOT-88_hide_join_and_l…
…eave [Feature] [UABOT-88] Hide join and leave messages
- Loading branch information
Showing
6 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Composer } from 'grammy'; | ||
|
||
import type { GrammyContext } from '../../types'; | ||
import { onlyNotDeletedFilter } from '../filters'; | ||
|
||
/** | ||
* @description Remove join and leave messages from chat | ||
* */ | ||
export const getJoinLeaveComposer = () => { | ||
const joinLeaveComposer = new Composer<GrammyContext>(); | ||
|
||
joinLeaveComposer | ||
// Filter that feature is enabled | ||
.filter((context) => !context.chatSession.chatSettings.disableDeleteServiceMessage) | ||
// Filter if the message is already deleted | ||
.filter((context) => onlyNotDeletedFilter(context)) | ||
// Queries to filter | ||
.on([':new_chat_members', ':left_chat_member']) | ||
// Delete message | ||
.use(async (context, next) => { | ||
await context.deleteMessage(); | ||
return next(); | ||
}); | ||
|
||
return { joinLeaveComposer }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters