How to obtain private channel name from a forwarded message? - telegram

How to obtain a private channel name from a forwarded message? So the question is: if someone forwards a message from the private channel to the public channel\group or in DM, in the Telegram application you will see the name of this channel. But when you get this forwarded message by telethon you can get only channel ID. Using this ID is useless because on any request you will get telethon.errors.rpcerrorlist.ChannelPrivateError: The channel specified is private and you lack permission to access it. Another reason may be that you were banned from it (caused by GetBroadcastStatsRequest)
Is it function missed in telethon or I just didn't find it? Thanks for any support.

Related

Google Calendar Push Notification Channel subscription Creation

I have to create calendar push notification but didn't undersatnd how to create channel subscription ?
private void perormWatch(Calendar service, String user) throws Exception {
Channel content = new Channel();
content.setId("abcd#gmail.com");
content.setType("web_hook");
content.setAddress("http://localhost:8888/calendarNotiication");
com.google.api.services.calendar.Calendar.CalendarList.Watch cal = service.calendarList().watch(content);
}
I assume that you want to set up a channel with CalendarList.watch(). To do so you must satisfy three minimum requirements:
An id that uniquely identifies this new channel within your project.
The type property set on web_hook
An address over HTTPS where you want to receive the notifications.
By keeping that in mind, you only have to update your script to match the requirements. First of all the address is set to an invalid URL in the example. It must start with https, not http. Please be aware that only valid SSL certificates are acceptable (i.e. not selfsigned certificates, revoked or badly formed). Also please check that the id is truly unique within your project. Those small modifications should suffice in the example code, but feel free to update your question and leave a comment if you need further solutions.

Poco HTTPSClient session by IP address

I'm trying to use Poco HTTPS client session to download a site from hostname by specific IP address.
For example, google.com has the following addresses:
173.194.221.113
173.194.221.138
173.194.221.102
173.194.221.139
173.194.221.100
173.194.221.101
I want to get https://google.com via 173.194.221.102
I was trying the following approach:
std::make_unique<HTTPSClientSession>(SecureStreamSocket(SocketAddress(IPAddress("173.194.221.102"), 0), "https://google.com"));
This fails with the exception "Illegal state: Cannot set the port number for an already connected session"
Looking at the Poco source code, the SecureStreamSocket created with this constructor is connected, and the constructor of HTTPSClientSession tries to set the https port(443), and fails to do that with the already connected socket.
Any better way to do that?
Should be something like that:
Poco::Net::initializeSSL();
Poco::Net::HTTPSessionFactory::defaultFactory().registerProtocol("https", new Poco::Net::HTTPSSessionInstantiator);
const Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> certificateHandler(new Poco::Net::AcceptCertificateHandler(false));
const Poco::Net::Context::Ptr context(new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, ""));
Poco::Net::SSLManager::instance().initializeClient(nullptr, certificateHandler, context);
Poco::URI serverUri("your address");
Poco::Net::HTTPClientSession* session = Poco::Net::HTTPSessionFactory::defaultFactory().createClientSession(serverUri);
Hope it helps.

signalR: how to send a message to the user once, not to the number of ConnectionId

In the signalr, for each tag that opens, the ConnectionId registers for the user.
I use the following code to send messages to users.
1
2
hubContext.Clients.Clients (user.ConnectionIds.ToLi st ()); receiveNotification (message, userID, link);
The problem I have is that I want to send a message to the user once, not to the number of ConnectionId.
How can I find one of its active ConnectionIds and just send that message?
Is there a better way?
I also worked on this link
https://stackoverflow.com/questions/...ovider-new-2-0
But because of
I do not use request.User.Identity.Name, this method does not work. I'm using my user id. I'm reading the table.
value of request.User.Identity.Name in my app is empty because i'm reading user information from table in database
Thanks for your advice
You can retain connection and user information in a Map that is stored in memory.
private readonly Dictionary<T, HashSet<string>> _connections =
new Dictionary<T, HashSet<string>>();
You can find the fulle example here :
https://learn.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/mapping-users-to-connections

Why alive subscriber get only last published message

M2mqtt incorporate in my asp.net mvc project. Face problem to synch subscribe informations.
When more than one clients published on one specific topic, client can subscribe them easily.
suppose in one situation when published happen then client is down/offline when he alive then only get the last published message not all published messages.
What to do?Is it a problem on MQTT?How alive client get all published messages.
M2mqtt connection with broker use by bellow syntax
public static MqttClient SmartHomeMQTT { get; set; }
SmartHomeMQTT = new MqttClient(brokerAddress, MqttSettings.MQTT_BROKER_DEFAULT_SSL_PORT, true, new X509Certificate(Resource.ca), null, MqttSslProtocols.TLSv1_2, client_RemoteCertificateValidationCallback);
SmartHomeMQTT.Connect("6ea592c5-4b2f-481a-bb0a-eccbe8579d14", "####", "####", false, 3600);
**Note:**Connect method parameter four set to false for clean_session property but it's not work.
To ensure that subscribers receive all messages, even ones that are published when they are offline (known as message persistence), you need to do a few things:
Make sure that 'Clean Session' is turned off in the subscribers
Ensure that each subscriber is using a unique Client ID
Use a QoS of 1 or 2
You don't say which MQTT server you are using, but you need to ensure that the server implementation supports it too.

How to check MailMessage was delivered in .NET?

Is there a way to check if SmtpClient successfully delivered an email? SmtpClient.Send() does not appear to return anything other than an exception. So if the method completes is it safe to assume the email will be successfully sent to the appropriate email box? My code is below:
MailMessage emailMessage = new MailMessage();
emailMessage.Subject = SubjectText;
emailMessage.IsBodyHtml = IsBodyHtml;
emailMessage.Body = BodyText;
emailMessage.From = new MailAddress(Settings.Default.FromEmail,Settings.Default.FromDisplayName);
//add recipients
foreach (string recipientAddress in RecipientAddresses.Split(new char[{','},StringSplitOptions.RemoveEmptyEntries))
emailMessage.To.Add(recipientAddress);
using (SmtpClient smtpClient = new SmtpClient())
{
smtpClient.Send(emailMessage);
}
No, there is no reliable way to find out if a message was indeed delivered.
Doing so will require access to the end SMTP server for every person you are emailing.
If you do not get an exception, you can assume that the SMTP server did its best to deliver the email.
There's no way to be 100% sure that a mail message has been received when sent via SmtpClient due to the way email works. The fact that SmtpClient doesn't throw an exception essentially means that you've done everything right, but a failure can happen further down the line, for example:
The receiving mail server could reject the mail
An intermediate mail server could reject the mail
The server that SmtpClient is transmitting mail through could decide to refuse to transmit the mail
One solution you could use is to create an httphandler for your website images. If you send an HTML message which includes at least 1 image, then you could embed querystring data to the end of that image. This could even be something like a 1x1 transparent image. When the user reads the email, this sends the request to the server to fetch the image data, and in turn, you could capture that request and denote that the message was read.
This is not bulletproof however, because most email clients block images by default unless the user specifies they would like to view images in the email.
If the recipient e-mail address is valid you don't get an immediate return value about the successful delivery of the message; see the signature:
public void Send(MailMessage message)
The SMTP server will notify the sender (or whoever you specify for the notification) almost immediately with an 'Undeliverable' notification whenever the recipient e-mail address is invalid/fake.
SMTP servers are required to periodically retry delivery. When the recipient e-mail address is a valid address but for some reason the SMTP server could not deliver the message, the SMTP server will return a failure message to the sender if it cannot deliver the message after a certain period of time.
RFC 2821 contains more details.
From section 2.1 Basic Structure
In other words, message transfer can occur in a single connection
between the original SMTP-sender and the final SMTP-recipient, or can
occur in a series of hops through intermediary systems. In either
case, a formal handoff of responsibility for the message occurs: the
protocol requires that a server accept responsibility for either
delivering a message or properly reporting the failure to do so.
See sections 4.5.4 and 4.5.5
From section 6.1 Reliable Delivery and Replies by Email
If there is a delivery failure after acceptance of a message, the
receiver-SMTP MUST formulate and mail a notification message. This
notification MUST be sent using a null ("<>") reverse path in the
envelope. The recipient of this notification MUST be the address from
the envelope return path (or the Return-Path: line).

Resources