Skip to content

Update get_peer_type #143

@deathnoragami

Description

@deathnoragami

Checklist

  • I believe the idea is awesome and would benefit the framework
  • I have searched in the issue tracker for similar requests, including closed ones

Description

You can do it another way to recognize what kind of id it is. Instead of updating the range, since the user id is always positive, the group id always starts with -100, it's easier to do the logic

def get_peer_type(peer_id: int) -> str:
  peer_id_str = str(peer_id)
  if not peer_id_str.startswith("-"):
      return "user"
  elif peer_id_str.startswith("-100"):
      return "channel"
  else:
      return "chat"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions