Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle stories? #766

Open
PlugFox opened this issue Feb 21, 2025 · 1 comment
Open

How to handle stories? #766

PlugFox opened this issue Feb 21, 2025 · 1 comment

Comments

@PlugFox
Copy link

PlugFox commented Feb 21, 2025

I want to remove spammers and stories forward; how can I?

{
    "ok": true,
    "result": [
        {
            "update_id": 123,
            "message": {
                "message_id": 123,
                "from": {
                    "id": 123,
                    "is_bot": false,
                    "first_name": "Username,
                    "username": "Username"
                },
                "chat": {
                    "id": -123,
                    "title": "Chat",
                    "type": "supergroup"
                },
                "date": 1740159731,
                "story": {
                    "chat": {
                        "id": 123,
                        "first_name": "Name",
                        "last_name": "Name",
                        "username": "name",
                        "type": "private"
                    },
                    "id": 123
                }
            }
        }
    ]
}
@PlugFox
Copy link
Author

PlugFox commented Feb 21, 2025

Right now, I implemented it this way:

const onStory = "\astory" // Custom event for story messages
handlers := []interface{}{
	tele.OnText,
	tele.OnEdited,
	tele.OnUserJoined,
	tele.OnAddedToGroup,
	tele.OnPhoto,
	tele.OnAudio,
	tele.OnAnimation,
	tele.OnDocument,
	tele.OnSticker,
	tele.OnVideo,
	tele.OnVoice,
	tele.OnVideoNote,
	tele.OnContact,
	tele.OnLocation,
	tele.OnVenue,
	tele.OnPoll,
	tele.OnDice,
	tele.OnChannelPost,
	tele.OnMedia,
	tele.OnMyChatMember,
	tele.OnChatMember,
	onStory,
}

for _, handler := range handlers {
	bot.Handle(handler, func(_ tele.Context) error {
		return nil
	})
}

go func(b *tele.Bot) {
	for update := range bot.Updates {
		if update.Message != nil && update.Message.Story != nil {
			c := b.NewContext(update)
			b.Trigger(onStory, c)
		}
	}
}(bot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant