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

[NO BUG] some restricted chat members have zero 'until_date' and restricted status after finishing account limitation time #1803

Closed
ehsanonline opened this issue Mar 1, 2020 · 6 comments
Labels

Comments

@ehsanonline
Copy link
Contributor

ehsanonline commented Mar 1, 2020

Steps to reproduce

  1. limit a member from sending all types of messages using restrictChatMember for a short/long (not infinite) duration.

  2. let the time pass. after that the user can send messages but the getChatMember says that user is still limited but with zero duration.
    like this:

{'user': {'id': 123, 'first_name': 'USER', 'is_bot': False, 'language_code': 'fa'}, 
'status': 'restricted', 'until_date': 0, 
'is_member': True}

it will stays like this FOREVER. even when i used the restrictChatMember again to release the member (after passed limitation duration).
the only way to change the status to member is to make the user admin then member again ( i didn't use bot for doing that).

Expected behaviour

getChatMember return this after passing the limitation time (like earlier versions):

{'user': {'id': 123, 'first_name': 'USER', 'is_bot': False, 'language_code': 'fa'}, 'status': 'member', 'until_date': None}

Actual behaviour

the member status stays 'restricted', with 0 until_date. but the member can send messages.

Configuration

ubuntu 16.04 server

Version of Python, python-telegram-bot & dependencies:

python-telegram-bot 12.4.2
certifi 2018.08.24
future 0.16.0
Python 3.6.8 (default, Dec 24 2018, 19:24:27)  [GCC 5.4.0 20160609]

Logs

no logs

i'm not sure if this is just my group problem (never happened before) or the users problem (happened for two of them at least, one of them deleted her/his account but that doesn't help) or the telegram problem (after last update this problem started) or the library problem (always using latest). or just my code.
anyone else experiencing this problem?

@ehsanonline ehsanonline changed the title [BUG] restricted chat members has zero 'until_date' and 'restricted' status after finishing account limitation time in group chat [BUG] restricted chat members have zero 'until_date' and 'restricted' status after finishing account limitation time in group chat Mar 1, 2020
Copy link
Member

@ehsanonline Hi. This doesn't sound like something we could do something about... All PTB can do is get the result of getChatMember from Telegram. You could try and get the chat member via a direct http request to Telegram (like in a Browser) to see, if the outcome is different, but I strongly doubt that it will.

@ehsanonline
Copy link
Contributor Author

@Bibo-Joshi Thanks. So it's a telegram bug?

@Bibo-Joshi
Copy link
Member

Well, if the issue is not with PTB and all PTB does is leverage the Telegram Bot API, then yes, the issue must be with Telegram.

I double checked with two findings:

  1. I get the same result with PTB as with a https request
  2. After the set time passes, until_date is None.

Are you sure that you didn't restrict for less than 30 seconds/more than 366 days? (see the docs)

Closing, since the reported bug is no bug.

@Bibo-Joshi Bibo-Joshi changed the title [BUG] restricted chat members have zero 'until_date' and 'restricted' status after finishing account limitation time in group chat [NO BUG] restricted chat members have zero 'until_date' and 'restricted' status after finishing account limitation time in group chat Mar 2, 2020
@Bibo-Joshi Bibo-Joshi added API and removed bug 🐛 labels Mar 2, 2020
@ehsanonline
Copy link
Contributor Author

ehsanonline commented Mar 3, 2020

Yes, I'm sure that they were restricted for limited time, not infinite.
As I said, this happened only to two of the group members (so far), and they were released after passing the limitation time, they could sent messages and chat. but the getChatMember status said they were still 'restricted' with zero until_date.
I even used restrictChatMember to them to change their permission and set all of the ChatPermissions parameters to true, but it didn't help.
the only way to change their status to member again is to make them administrator of the chat and then member again.
I think it's a telegram bug too.

@ehsanonline ehsanonline changed the title [NO BUG] restricted chat members have zero 'until_date' and 'restricted' status after finishing account limitation time in group chat [NO BUG] some restricted chat members have zero 'until_date' and restricted status after finishing account limitation time Mar 3, 2020
@Bibo-Joshi
Copy link
Member

Okay. Maybe contact @botsupport about it.

@ehsanonline
Copy link
Contributor Author

ehsanonline commented Mar 13, 2020

I think I figure it out.
TL;DR: it was not telegram bot api bug, it was not PTB bug. it was just a misunderstood by me and maybe lack of documentation.

the problem was when i need to release a member from restriction, i used the restrictChatMember like this:

duration=0
bot.restrictChatMember(chat_id=chatid,user_id=userid,
        until_date=time.time()+duration,
        permissions = ChatPermissions(
          can_send_messages = True,
          can_send_media_messages = True,
          can_send_other_messages = True,
          can_add_web_page_previews = True,
        )
      )

It was working fine, but after the api and PTB updates, they have add new args to the ChatPermissions, which i didn't pass them to the function. can_send_polls,can_change_info,can_invite_users and can_pin_messages. the problem was the default value of these args is False. so my member was released (kind of), but he couldn't send polls and do those other actions which we weren't notice because these messages are rare and not used daily. in fact, the member was limited for those types infinity because of 0 duration. so i added the missing args and now it's working fine.

also i think it's better to set the default value of them to True. because a user is not restricted by default, unless he/she become one by an admin.
or at least note that in the documentation for other users like me!
thanks for helping.

This was referenced Mar 18, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants