rizaumami / tdcli.lua

A simple Lua library for the telegram-cli
GNU General Public License v3.0
52 stars 30 forks source link

How to get getUser(194211431) Response?? #6

Closed abbas980301 closed 7 years ago

abbas980301 commented 7 years ago

Hi. Thanks for good job. I was explorer your repo but i cant find the getUser Response handler. please help me.

I need fetch user info to find the phone number, and if he didn't share his phone number ask him to share it.

rizaumami commented 7 years ago

The response is from the callback, see this test script to see how. Note, you won't get the number of someone not in your contact.

abbas980301 commented 7 years ago

The response is from the callback, see this test script to see how.

I saw that, but i need do some process on response. I should use that in this way?

 tdcli_function ({
      ID="GetChats",
      offset_order_="9223372036854775807",
      offset_chat_id_=0,
      limit_=20
    }, dl_cb, nil)
rizaumami commented 7 years ago

Try getChannelMembers to get a chats members, iterate the members_ table to get the members id, then use getUserFull to get full information about each user.

abbas980301 commented 7 years ago

I looking for tdcli.getMe() response. due the repo Wiki this methods response is some thing like this.

{
  ID = "User",
  first_name_ = "Abon",
  foreign_link_ = {
    ID = "LinkStateKnowsPhoneNumber"
  },
  have_access_ = true,
  id_ = 194211431,
  is_verified_ = false,
  last_name_ = "Ketimus",
  my_link_ = {
    ID = "LinkStateKnowsPhoneNumber"
  },
  phone_number_ = "REDACTED",
  profile_photo_ = {
    ID = "ProfilePhoto",
    big_ = {
      ID = "File",
      id_ = 2,
      path_ = false,
      persistent_id_ = "AQADBQADW6gxG2dukwsACBVQyjIABC8HS8ezO2hr1XkDAAEC",
      size_ = 0
    },
    id_ = "834131745110599771",
    small_ = {
      ID = "File",
      id_ = 1,
      path_ = false,
      persistent_id_ = "AQADBQADW6gxG2dukwsACBVQyjIABAt-RZr5h2xE03kDAAEC",
      size_ = 0
    }
  },
  restriction_reason_ = false,
  status_ = {
    ID = "UserStatusOnline",
    expires_ = 1496992157
  },
  type_ = {
    ID = "UserTypeGeneral"
  },
  username_ = false
}

after using tdcli.getMe() in my code, how i can fetch my phone_number_??

rizaumami commented 7 years ago

Process the callback (response), ie:

tdcli.getMe(function(a, d)
  print(d.phone_number_)
end)

I'm closing this as it's not a tdcli.lua issue.