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

switch to OvyFlash/telegram-bot-api (updated fork of the same lib) #180

Merged
merged 2 commits into from
Dec 1, 2024

Conversation

paskal
Copy link
Collaborator

@paskal paskal commented Nov 23, 2024

Everything left the same except

  • "is_premium" flag about user is now known and logged
  • username of the hidden user would be detected properly in more places

I tested the changes as much as I could to verify everything works the same.

@paskal paskal requested a review from umputun as a code owner November 23, 2024 03:15
Copy link

cloudflare-workers-and-pages bot commented Nov 23, 2024

Deploying tg-spam with  Cloudflare Pages  Cloudflare Pages

Latest commit: b9f69ee
Status: ✅  Deploy successful!
Preview URL: https://feb4ccee.tg-spam.pages.dev
Branch Preview URL: https://paskal-switch-to-newer-tb-li.tg-spam.pages.dev

View logs

@paskal paskal marked this pull request as draft November 23, 2024 03:24
@paskal paskal force-pushed the paskal/switch_to_newer_tb_lib branch from 38b97cd to 81ff787 Compare November 23, 2024 03:32
Everything left the same except
- "is_premium" flag about user is now known and logged
- username of the hidden user would be detected properly in more places
@paskal paskal force-pushed the paskal/switch_to_newer_tb_lib branch from 81ff787 to 1513255 Compare November 23, 2024 03:38
@paskal paskal marked this pull request as ready for review November 23, 2024 03:39
Copy link
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work. just a few minor things and some questions

app/events/events.go Show resolved Hide resolved
app/events/admin.go Outdated Show resolved Hide resolved
app/events/admin.go Outdated Show resolved Hide resolved
@@ -485,12 +519,16 @@ func (a *admin) callbackUnbanConfirmed(query *tbapi.CallbackQuery) error {
func (a *admin) unban(userID int64) error {
if a.softBan { // soft ban, just drop restrictions
_, err := a.tbAPI.Request(tbapi.RestrictChatMemberConfig{
ChatMemberConfig: tbapi.ChatMemberConfig{UserID: userID, ChatID: a.primChatID},
ChatMemberConfig: tbapi.ChatMemberConfig{UserID: userID, ChatConfig: tbapi.ChatConfig{ChatID: a.primChatID}},
Permissions: &tbapi.ChatPermissions{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Permissions list is arbitrary and always has been. I'm not sure what the correct way to deal with this. Maybe TG has a way to know "default permissions"? Btw, in this case, you dropped the Pools permission for some reason, but I can see cases where chat allows pools for users, and we may want to restore it upon unban.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description for polls:

CanSendPolls is true, if the user is allowed to send polls, implies can_send_messages

We don't need to care about it as we remove ability to send messages. I've left CanSendOtherMessages which works the same for backwards compatibility, as otherwise previously issued softbans won't restore that permission on unban.

app/events/events.go Show resolved Hide resolved
if update.Message.Chat == nil {
log.Print("[DEBUG] ignoring message not from chat")
continue
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the removed check for update.Message.Chat make me worry

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case doesn't exist anymore as Chat is not a pointer and I have no idea how to trigger it.

@paskal paskal requested a review from umputun November 23, 2024 14:24
1. Extracts forward message handling into a separate method
2. Improves error checking for delete message operations
3. Simplifies code structure and reduces duplication
@paskal paskal force-pushed the paskal/switch_to_newer_tb_lib branch from c6b738f to b9f69ee Compare November 23, 2024 14:30
@umputun
Copy link
Owner

umputun commented Nov 25, 2024

This branch has been running on a real chat with about 9k users, and I have not seen any problems yet. I will let it run for a few more days before the merge to master.

@umputun umputun merged commit 3a537f8 into master Dec 1, 2024
5 checks passed
@umputun umputun deleted the paskal/switch_to_newer_tb_lib branch December 1, 2024 19:10
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

Successfully merging this pull request may close these issues.

2 participants