How to change emoji status in Telegram by Telethon? - telegram

In the new Telegram update, it is possible for premium users to install emoji status. Is it possible to implement this through Telethon?

This will be possible once v1.26 is released (which isn't at the time of writing) once this PR is merged. If you install the development version with these changes, or your Telethon version is v1.26 or higher, you can use telethon.tl.functions.account.UpdateEmojiStatusRequest to change your status. It will require a telethon.tl.types.EmojiStatus instance, which itself requires the document_id of the emoji you want.

I believe it'd be actually like that:
from telethon.sync import TelegramClient
from telethon import functions, types
with TelegramClient(name, api_id, api_hash) as client:
result = client(functions.account.UpdateEmojiStatusRequest(
emoji_status=types.EmojiStatus(
document_id=-12398745604826
)
))
print(result)
because UpdateEmojiStatusRequest expects a types.EmojiStatus, not s string - according to https://github.com/telegramdesktop/tdesktop/blob/2a6e2fa353d5c4b7ab6a05eef5ce8952c78c2a73/Telegram/Resources/tl/api.tl#L1557

Related

How to find out session name of telegram app?

I have created a telegram app via https://my.telegram.org. After I did that I got data about api_id and api_hash but I can't find session name. Where can I find it?
When I use telethon function TelegramClient, I need to pass there SESSION:
from telethon import TelegramClient
client = TelegramClient(SESSION, API_ID, API_HASH)
I can't find the session name
Where can I find it?
You cant, you'll need to create it.
Telethon sessions are used to save the data of your current session.
They're not part of the Telegram API, just something Telethon introduced.
The first parameter you pass to the constructor of the TelegramClient is the session, and defaults to be the session name (or full path). That is, if you create a TelegramClient('anon') instance and connect, an anon.session file will be created in the working directory.
The file name of the session file to be used if a string is given (it may be a full path), or the Session instance to be used otherwise. If it’s None, the session will not be saved, and you should call log_out() when you’re done.
You can just pass None (to not save a session), or a 'usefull' name like Anon:
client = TelegramClient('anon', '19071234', 'e40ef8a46648716835434')
client.start()

How do I perform Firestore admin tasks from a server-side Dart application?

I'm working on putting together a server-side Dart application that will run in App Engine. It needs to access a Firestore database, but I'm having trouble doing so.
The Dart packages I've tried are:
firebase_admin_interop
firebase
In both cases, I get errors like this when attempting to execute my code:
file:///root/.pub-cache/hosted/pub.dartlang.org/firebase_admin_interop-1.2.2/lib/src/database.dart:5:8: Error: Not found: 'dart:js'
import 'dart:js';
My vague understanding of this error is that it means the library has a dependency on running in a browser. However, I've not been able to find any way to interact with Firestore in a server-to-server configuration using Dart.
Is my only recourse here to use the Firestore REST API?
There is no Firebase Admin SDK for Dart. So indeed the REST API would be your best best.
Note that much of the Admin functionality is not exposed in documented REST API. So ymmv, and I'd seriously consider switching to a platform where you can use one of the official Admin SDKs.
If the number of search results on google are an indicator for popularity, then
Go, Node.js and C# are the languages most people use with the firestore admin libraries
Google searched input taken from https://cloud.google.com/firestore/docs/quickstart-servers
Go: "cloud.google.com/go/firestore" -> 3890 results
Node.js: "require('#google-cloud/firestore')" -> 2120 results
C#: "FirestoreDb.Create" -> 1110
Python: "from google.cloud import firestore" -> 859 results
Java: "import com.google.cloud.firestore.Firestore" -> 601 results
PHP: "Google\Cloud\Firestore\FirestoreClient" -> 1 result

Read the messages of the public channels from Telegram

I need to read the messages of some public channels in the application, as for example it happens https://tlgrm.ru/channels/tech As I understood, the bot for this business will not work. You need to use client api, but everywhere that with the channel methods are connected everywhere you need channel_id but where do I get it I do not know, I only have channel names, and how do I get it from it id I did not find such a method.
How can I get the channel's id by its name?
Assuming you're using python, I suggest Telethon library. You can use this piece of code to get channel_id and access_hash from #username:
from telethon.tl.functions.contacts import ResolveUsernameRequest
client = TelegramClient(session_file, api_id=X, api_hash='X')
client.connect()
response = client.invoke(ResolveUsernameRequest("username"))
print(response.channel_id)
print(response.access_hash)
Make sure you have already got your api_id and api_hash. And also make sure you have authenticated your app i.e. you have a working session_file. Just read Telethon's README in the Github page if you're not sure how to perform above steps.
In the latest version, you would do like this using the username of the channel
from telethon.tl.functions.contacts import ResolveUsernameRequest
response = client.invoke(ResolveUsernameRequest(<username>))
messages = client.get_message_history(response.peer,limit=1000)

Can I use UUID to identify developers in OpenStack?

I have a problem. The openstack community provide the MySQL database dumps with the complete datasets.
I want to identify the same developers in different data schemas. And I find in different data schemas, there is a date file named 'people_uidentities', which provides the people id and his uuid as the
.
Because I find many developers who have same name but have different uuids in different schemas. Take 'Thai Tran' as an example, his uuid in openstack_sourcecode and openstack_tickets are different.
uuid in openstack_sourcecode:
uuid in openstack_tickets:
My question is what the generation mechanism of uuid in OpenStack is.
Can one person have serval uuids?
Thank you for you help!
I am not sure about the answer for the general mechanism of uuid in OpenStack. But one user account can only have one uuid that refers to the account. And you can use the uuid to get the username. For example, if you are using the keystone client library (https://docs.openstack.org/python-keystoneclient/latest/using-api-v3.html):
from keystoneauth1.identity import v3
from keystoneauth1 import session
from keystoneclient.v3 import client
auth = v3.Password(auth_url='https://my.keystone.com:5000/v3',
user_id='myuserid',
password='mypassword',
project_id='myprojectid')
sess = session.Session(auth=auth)
keystone = client.Client(session=sess)
You have to be an admin role in the OpenStack to run the following commands:
user = keystone.users.get("###") # user's uuid to replace "###"
user.name
HTH.

Can I use glib to make some portable http GET request and how?

Was just wondering if any of you already coded a http get request using glib?
Is it possible and how ?
I just want to call an simple urls with parameters, and the code must be working on gnu/linux, windows and mac.
If it is not possible with glib, have you any suggestion about what to use for that purpose (in a portable perspective).
I want to avoid if possible 3rd party libs to minimize my project dependencies. So in that case of glib is not the right way, any code fragment will be welcome !
Thanks
Sinn'
Yes, you can use libsoup. It's part of GNOME, and designed for use with GLib. You can start with the howto. E.g. it shows how to create a basic GET request:
SoupMessage *msg;
msg = soup_message_new ("GET", "http://example.com/");
SoupSession *session = soup_session_sync_new();
guint status = soup_session_send_message (session, msg);

Resources