How do I check user by ID or Name? - telethon

I want to check if the message what I got comes form the particular user and I want to check him by his Name or ID, because for some users I don't know the Id yet. Is there a good way to do it?

Related

Laravel get a random user with where clause

My table schema is a id field, name field and a friends id field.
Every user must have a maximum of 2 friends. When a new user is created and event is fired and a listener which listens to the created user event then adds a random friend to a newly created user.
$randomfriend = DB::table('users')->select('id')
->groupBy('friends_id')
->havingRAW('COUNT(*) < 2')
->inRandomOrder()->first();
it still returns users with maximum number of friends. Can someone help me with this?
first of all create another table for friends relations.
for selecting a random user this post can help you:
enter link description here
don't forget to put this code in while loop for checks.

Objective C Full Name to Logon Name

I have a user's full name (like the one returned by NSFullUserName()). Is there any way in c or objective c to confert this to a logon name (like the one returned by NSUserName()).
However, I cannot use NSFullUserName() because the full name I have is not necessarily the name of the currently logged in user.
The login name (NSUserName) and the full/display name (NSFullUserName) have no automated relationship. A user, when creating an account or at any time afterward in System Preferences, can choose whatever they like for both names — so there's no way to generate one given the other and be guaranteed it's correct.

fetching user media from instagram api without user id

I did what #krisrak told me to do. I used two API calls.
One to search for the username with
https://api.instagram.com/v1/users/search?count=1&q=USERNAME
and i got the user id from there to perform the second API call
The second call was
https://api.instagram.com/v1/users/USER-ID/media/recent/
This worked perfectly until I searched a certain username and I was given another. So I want to know if there's a sort of where clause to use to get the username I want from a list of results gotten. So my 1st call would now be
https://api.instagram.com/v1/users/search?count=0&q=USERNAME
to enable me get all results.
If there is no match, then that username probably does not exists, go to instagram.com/USERNAME and check if it exists. You may have to ignore and display that username does not exist.
BTW to get all the results, just remove count=1, then it will return a bunch of usernames that match similar search, usually the first one will be the exact match, so thats the reason count=1 is used to match a particular username.
https://api.instagram.com/v1/users/search?q=USERNAME

iPhone Addressbook and contact id? does it ever change?

Each contact in the address book, has a unique Id,
1) will this Id ever change? if so when does it change? ie a user deletes a contact, will the other contact id change? how do we make sure of this? will not change now or in the future.
EDIT: would like to uniquely identify a contact, which id should I use as a reference?
The documentation says:
The recommended way to keep a
long-term reference to a particular
record is to store the first and last
name, or a hash of the first and last
name, in addition to the identifier.
When you look up a record by ID,
compare the record’s name to your
stored name. If they don’t match, use
the stored name to find the record,
and store the new ID for the record.
Have one unique field like contact or address and compare the record's name with that field as well as id.

How should I handle entries when the user is deleted?

I run a forum which I built myself. Ok so all users have the opportunity to delete themselves.
But all their threads and posts will remain. But right now where it should say their username it's just blank.
How should I handle this?
Should I make a new user and call it e.g. "deleted user" and assign all threads/posts to that ID when they delete themselves?
Or should I just check if the user ID exist if not print e.g. "deleted user" as username?
What's the smartest way? Any other ways tell me.
Thanks!
p.s (i'm not a native english speaker, looked up some fancy words on a online dictionary)
I would suggest not actually deleting the user. You could simply add a column to the users table such as:
ALTER TABLE users ADD COLUMN (is_active TINYINT(1) NOT NULL DEFAULT 1);
Then when you "delete" a user, simply mark them as inactive:
UPDATE users SET is_active = 0 WHERE users.id = 7;
For user listings, and account access you would check the is_active status. For displaying of data such as posts and what not, you'd not care about their active status, youd just grab the name from the table.