Getting member id of a specific member in telegram group - telegram

I have a telegram bot that can do several tasks in my telegram group.
I want to add a new task that can count the number of messages a specific user sends in a group.
Every time it will be updated, Let say a user name drhunter, if he sends a message then it will save in a text file as,
drhunter 1 for the next message will be updated to drhunter 2 and so on.
I can do it using telegram username but If a user hasn't set username then occurs a problem. It shows None
I get username using message.from_user.username
I use username & count the number of messages each time then save it in a file. Like this
count.txt
drhunter 5
drhunter2 45
Is there any way to do this? or more specifically is there any way to identify a telegram user without their username (inside a telegram group)?

Use the id instead, which is a unique identifier for the user independent of whether the user has a username.

Related

Can WebAuthN be used to identify an individual?

I'm wondering whether WebAuthN APIs can be used to identify an individual. Do any of the following hold
Can the authenticator ever return info about the individual e.g. First name, email etc
Will the authenticator always give us the same ID back for Alice when she uses this device regardless of which website I'm requesting from?
Will different devices ever give back the same ID for the same user?
Can the authenticator ever return info about the individual e.g. First name, email etc
It can if you set personally-identifying information to the value of user.id in the options you pass to navigator.credentials.create(). Also referred to as the "user handle", the spec includes a section specifically about how this value is one way the API can leak personally-identifying information if you're not careful what value you set user.id to.
Will the authenticator always give us the same ID back for Alice when she uses this device regardless of which website I'm requesting from?
The authenticator will not give back the same ID on every website. Every successful invocation of navigator.credentials.create() generates a unique credential bound to the website, meaning every website would have to use the same value for Alice's internal user ID for this to even have a chance of happening. And for any given website the authenticator only gives back the value of user.id (as passed into navigator.credentials.create()) as userHandle in the response from navigator.credentials.get() when Alice logs into that site.
Will different devices ever give back the same ID for the same user?
Different registered authenticators would give back the same ID for Alice provided you specify the same value for user.id whenever Alice registers an authenticator.

How to forward (filter) Telegram messages from a private group to myself based on sender?

I'm in a private Telegram group that has a continual stream of many messages from a large number of people. I need to somehow pull out just those from a handful of specific people, and forward them to myself somehow - e.g. a new group I'm the only member of, or private chat, or some other way (email?). I just need to read them, not reply.
I'm a full stack developer (PHP back end but willing to consider others if works better) and know how to interface with APIs etc so can write some code to do this.
Can anyone advise on what API functions I'd use, or other approach here - and is it the Telegram or Bots API? Or is there a pre-existing solution out there?
Asking here as I've done my own research and not finding any solutions!
You can create a bot and put it in the private group. Set the bot as administrator so it can read all messages from all users. For each message the users send in the group, the bot will recive an update containing a message object. The message object contains all the information about the message just sent in the group, including the user's data. To filter a message from a specific user you can compare the user_id in $update['message']['from']['id'] with an array containing all the user_ids of the users you want to forward their messages to you, with the in_array php function passing the user_id and the array. Then, if it match, use the forwardMessage method with these parameters:
{
"chat_id": "YOUR_USER_ID",
"from_chat_id": "PRIVATE_GROUP_CHAT_ID",
"message_id": "THE_FILTERED_MESSAGE_ID"
}
If you use your user_id in the chat_id field, the bot will forward the message from the private group to your chat with it. The from_chat_id field is the chat_id of the private group (you can get it from $update['message']['chat']['id']). The message_id is the unique identifier for a message in that private group. It's contained in $update['message']['message_id'].
Instead of comparing the user_id to filter users, you can compare the first_name, last_name or username of the users but only the user_id is unique for each user and can not be changed.
You are using the Bot API.

How to make auto respond bot to new member joined in groups without type command

How to make auto respond bot to new member joined in groups without type command?
Look at this picture:
Bot send new text when users joined in groups
When a user is added to a group, an update is sent to the bot. In it message field, there is another field, called new_chat_members, that contains an array of User objects that were added to the group. You should send the appropriate message when such an update is received. (You can use information provided in User objects to get information about those users, e.g. Their name, to include it into your message.)

NoSQL query of items,lists, Groups and Users using Firebase

Am looking at the data structure in this post and want to know how you would go about getting the emails of users who belong to a certain group when they could belong to several groups and the GroupID stored against that user is the current group they are participating in?
Do you store the email addresses with the userid under the "members" or, instead, for each member of the group, get that user's email address from the "users" document userid (this would mean iterating through the group/members collection and doing a query for each user. Not very efficient).
Am used to SQL so this is all new to me.
You should have a single node for each user
/users/UID/emails/
/users/UID/emailunread/
/users/UID/settings/
/users/UID/details/
/users/UID/payments/
So you can simply do a subscription for a singular node path this.myDatasubscription = this.DB.list('users/' + this.uid).snapshotChanges() ensuring changes like new emails or account settings will detected and rolled out in real time back to the app, so your are using angular/ng or something similar client side then your variables {{this.email_list}} should update real time with no page changes.
Take a look at this one.
error: Property 'getChildren' does not exist on type 'DataSnapshot'

Custom metric to track email opens

I am trying to track the number of email opens of a mailing.
This mailing is not personalised, so each receiver will get exactly the same email contents.
So far I have found out that I can add a tracking pixel in the mailing, which will send data to GA that a user opened the mail (images were loaded).
Example code:
<img src=”http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-X
&cid=EmailOpenTest&t=event&ec=email&ea=open&el=EmailOpenTest
&cs=newsletter&cm=email&cn=Email&cm1=1″ />
'tid' will be our custom tracking ID.
This all works, as when this link is opened the total number of hits increases.
But my question relates to parameter 'cid'. For testing purposes, I have set this here to "EmailOpenTest". But this should be a random/unique ID per user actually. But as the mailing is not personalised, I wonder if it would be possible to track individual users?
Does this mean I have to include javascript in the mail? Would that even work in all email clients? Or are there other options?
All suggestions are welcome.
Assumption: you are using a mail client like Mail Chimp
Assign a unique id to every email on the email list. lets say this unique id is uid
Create a custom dimension in GA, lets name it as Client Mail Id with index say 1
Create the same pixel just like you have created above in the OP.
Add a custom Dimension in the hit as
http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-X
&cid=EmailOpenTest&t=event&ec=email&ea=open&el=EmailOpenTest
&cs=newsletter&cm=email&cn=Email&cm1=1&cd1=uid
In place of uid, you actually need to pass the mail list unique id for that email
How it will work
Once the user sends this hit, your unique id will be recorded in custom dimension 1.
Generate a custom report in GA with event category=email & event action=open and add a dimension custom dimension 1.
All the id's displayed there have actually opened the email ;)
PS: It's tried and tested, so won't cause any issue. Also if you don't want to use custom dimensions, you can also send this id in event label or event value
PPS: In any mail client, getting unique value for that email is pretty easy. You can actiually use its position number or add another column for the unique id, then grab that id win the template
The cid is the clientId, an identifier that is used to aggregate pageviews into sessions, and sessions into unique users.
The way to use that in email-tracking would be to capture the client id when a user subscribes to your newsletter and then insert it into the email links. Since your mails are not personalized this will not work.
If you use a random ID you will not be able to link the request from the mail to an existing user. So one way to deal with the problem would be to ignore it - using a constant userId would still give you an event count (the unique events metric might be a little of if users click the link multiple times within a session lifetime).
If for some reason you absolutely need to track these as different users you can set up a redirect - do not send data to ga directly from your mail, instead call a script on your server that inserts a random clientId and then sends the data to Google.

Resources