repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
LonamiWebs/Telethon | telethon/network/connection/connection.py | Connection.disconnect | async def disconnect(self):
"""
Disconnects from the server, and clears
pending outgoing and incoming messages.
"""
self._connected = False
await helpers._cancel(
self._log,
send_task=self._send_task,
recv_task=self._recv_task
... | python | async def disconnect(self):
"""
Disconnects from the server, and clears
pending outgoing and incoming messages.
"""
self._connected = False
await helpers._cancel(
self._log,
send_task=self._send_task,
recv_task=self._recv_task
... | [
"async",
"def",
"disconnect",
"(",
"self",
")",
":",
"self",
".",
"_connected",
"=",
"False",
"await",
"helpers",
".",
"_cancel",
"(",
"self",
".",
"_log",
",",
"send_task",
"=",
"self",
".",
"_send_task",
",",
"recv_task",
"=",
"self",
".",
"_recv_task"... | Disconnects from the server, and clears
pending outgoing and incoming messages. | [
"Disconnects",
"from",
"the",
"server",
"and",
"clears",
"pending",
"outgoing",
"and",
"incoming",
"messages",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/connection/connection.py#L97-L113 | train | Disconnects from the server and clears pending outgoing and incoming messages. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/network/connection/connection.py | Connection.send | def send(self, data):
"""
Sends a packet of data through this connection mode.
This method returns a coroutine.
"""
if not self._connected:
raise ConnectionError('Not connected')
return self._send_queue.put(data) | python | def send(self, data):
"""
Sends a packet of data through this connection mode.
This method returns a coroutine.
"""
if not self._connected:
raise ConnectionError('Not connected')
return self._send_queue.put(data) | [
"def",
"send",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"self",
".",
"_connected",
":",
"raise",
"ConnectionError",
"(",
"'Not connected'",
")",
"return",
"self",
".",
"_send_queue",
".",
"put",
"(",
"data",
")"
] | Sends a packet of data through this connection mode.
This method returns a coroutine. | [
"Sends",
"a",
"packet",
"of",
"data",
"through",
"this",
"connection",
"mode",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/connection/connection.py#L115-L124 | train | Sends a packet through this connection mode. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/network/connection/connection.py | Connection.recv | async def recv(self):
"""
Receives a packet of data through this connection mode.
This method returns a coroutine.
"""
while self._connected:
result = await self._recv_queue.get()
if result: # None = sentinel value = keep trying
return re... | python | async def recv(self):
"""
Receives a packet of data through this connection mode.
This method returns a coroutine.
"""
while self._connected:
result = await self._recv_queue.get()
if result: # None = sentinel value = keep trying
return re... | [
"async",
"def",
"recv",
"(",
"self",
")",
":",
"while",
"self",
".",
"_connected",
":",
"result",
"=",
"await",
"self",
".",
"_recv_queue",
".",
"get",
"(",
")",
"if",
"result",
":",
"# None = sentinel value = keep trying",
"return",
"result",
"raise",
"Conn... | Receives a packet of data through this connection mode.
This method returns a coroutine. | [
"Receives",
"a",
"packet",
"of",
"data",
"through",
"this",
"connection",
"mode",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/connection/connection.py#L126-L137 | train | Receives a packet of data through this connection mode. This method returns a coroutine which will return the value of the first available item in the receive queue. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/network/connection/connection.py | Connection._send_loop | async def _send_loop(self):
"""
This loop is constantly popping items off the queue to send them.
"""
try:
while self._connected:
self._send(await self._send_queue.get())
await self._writer.drain()
except asyncio.CancelledError:
... | python | async def _send_loop(self):
"""
This loop is constantly popping items off the queue to send them.
"""
try:
while self._connected:
self._send(await self._send_queue.get())
await self._writer.drain()
except asyncio.CancelledError:
... | [
"async",
"def",
"_send_loop",
"(",
"self",
")",
":",
"try",
":",
"while",
"self",
".",
"_connected",
":",
"self",
".",
"_send",
"(",
"await",
"self",
".",
"_send_queue",
".",
"get",
"(",
")",
")",
"await",
"self",
".",
"_writer",
".",
"drain",
"(",
... | This loop is constantly popping items off the queue to send them. | [
"This",
"loop",
"is",
"constantly",
"popping",
"items",
"off",
"the",
"queue",
"to",
"send",
"them",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/connection/connection.py#L139-L155 | train | This loop is constantly popping items off the send queue and sending them to the server. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/network/connection/connection.py | Connection._recv_loop | async def _recv_loop(self):
"""
This loop is constantly putting items on the queue as they're read.
"""
while self._connected:
try:
data = await self._recv()
except asyncio.CancelledError:
break
except Exception as e:
... | python | async def _recv_loop(self):
"""
This loop is constantly putting items on the queue as they're read.
"""
while self._connected:
try:
data = await self._recv()
except asyncio.CancelledError:
break
except Exception as e:
... | [
"async",
"def",
"_recv_loop",
"(",
"self",
")",
":",
"while",
"self",
".",
"_connected",
":",
"try",
":",
"data",
"=",
"await",
"self",
".",
"_recv",
"(",
")",
"except",
"asyncio",
".",
"CancelledError",
":",
"break",
"except",
"Exception",
"as",
"e",
... | This loop is constantly putting items on the queue as they're read. | [
"This",
"loop",
"is",
"constantly",
"putting",
"items",
"on",
"the",
"queue",
"as",
"they",
"re",
"read",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/connection/connection.py#L157-L188 | train | This loop is constantly putting items on the receive queue as they re read. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/network/connection/connection.py | Connection._init_conn | def _init_conn(self):
"""
This method will be called after `connect` is called.
After this method finishes, the writer will be drained.
Subclasses should make use of this if they need to send
data to Telegram to indicate which connection mode will
be used.
"""
... | python | def _init_conn(self):
"""
This method will be called after `connect` is called.
After this method finishes, the writer will be drained.
Subclasses should make use of this if they need to send
data to Telegram to indicate which connection mode will
be used.
"""
... | [
"def",
"_init_conn",
"(",
"self",
")",
":",
"if",
"self",
".",
"_codec",
".",
"tag",
":",
"self",
".",
"_writer",
".",
"write",
"(",
"self",
".",
"_codec",
".",
"tag",
")"
] | This method will be called after `connect` is called.
After this method finishes, the writer will be drained.
Subclasses should make use of this if they need to send
data to Telegram to indicate which connection mode will
be used. | [
"This",
"method",
"will",
"be",
"called",
"after",
"connect",
"is",
"called",
".",
"After",
"this",
"method",
"finishes",
"the",
"writer",
"will",
"be",
"drained",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/connection/connection.py#L190-L200 | train | Initialize the connection to Telegram. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/core/gzippacked.py | GzipPacked.gzip_if_smaller | def gzip_if_smaller(content_related, data):
"""Calls bytes(request), and based on a certain threshold,
optionally gzips the resulting data. If the gzipped data is
smaller than the original byte array, this is returned instead.
Note that this only applies to content related requ... | python | def gzip_if_smaller(content_related, data):
"""Calls bytes(request), and based on a certain threshold,
optionally gzips the resulting data. If the gzipped data is
smaller than the original byte array, this is returned instead.
Note that this only applies to content related requ... | [
"def",
"gzip_if_smaller",
"(",
"content_related",
",",
"data",
")",
":",
"if",
"content_related",
"and",
"len",
"(",
"data",
")",
">",
"512",
":",
"gzipped",
"=",
"bytes",
"(",
"GzipPacked",
"(",
"data",
")",
")",
"return",
"gzipped",
"if",
"len",
"(",
... | Calls bytes(request), and based on a certain threshold,
optionally gzips the resulting data. If the gzipped data is
smaller than the original byte array, this is returned instead.
Note that this only applies to content related requests. | [
"Calls",
"bytes",
"(",
"request",
")",
"and",
"based",
"on",
"a",
"certain",
"threshold",
"optionally",
"gzips",
"the",
"resulting",
"data",
".",
"If",
"the",
"gzipped",
"data",
"is",
"smaller",
"than",
"the",
"original",
"byte",
"array",
"this",
"is",
"re... | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/core/gzippacked.py#L14-L25 | train | Returns gzipped bytes if the gzipped data is smaller than the original byte array. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/parsers/tlobject/tlobject.py | TLObject.sorted_args | def sorted_args(self):
"""Returns the arguments properly sorted and ready to plug-in
into a Python's method header (i.e., flags and those which
can be inferred will go last so they can default =None)
"""
return sorted(self.args,
key=lambda x: x.is_flag... | python | def sorted_args(self):
"""Returns the arguments properly sorted and ready to plug-in
into a Python's method header (i.e., flags and those which
can be inferred will go last so they can default =None)
"""
return sorted(self.args,
key=lambda x: x.is_flag... | [
"def",
"sorted_args",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"self",
".",
"args",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"is_flag",
"or",
"x",
".",
"can_be_inferred",
")"
] | Returns the arguments properly sorted and ready to plug-in
into a Python's method header (i.e., flags and those which
can be inferred will go last so they can default =None) | [
"Returns",
"the",
"arguments",
"properly",
"sorted",
"and",
"ready",
"to",
"plug",
"-",
"in",
"into",
"a",
"Python",
"s",
"method",
"header",
"(",
"i",
".",
"e",
".",
"flags",
"and",
"those",
"which",
"can",
"be",
"inferred",
"will",
"go",
"last",
"so"... | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/parsers/tlobject/tlobject.py#L59-L65 | train | Returns the arguments properly sorted and ready to plug - in
into a Python s method header. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/sessions/sqlite.py | SQLiteSession._cursor | def _cursor(self):
"""Asserts that the connection is open and returns a cursor"""
if self._conn is None:
self._conn = sqlite3.connect(self.filename,
check_same_thread=False)
return self._conn.cursor() | python | def _cursor(self):
"""Asserts that the connection is open and returns a cursor"""
if self._conn is None:
self._conn = sqlite3.connect(self.filename,
check_same_thread=False)
return self._conn.cursor() | [
"def",
"_cursor",
"(",
"self",
")",
":",
"if",
"self",
".",
"_conn",
"is",
"None",
":",
"self",
".",
"_conn",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"filename",
",",
"check_same_thread",
"=",
"False",
")",
"return",
"self",
".",
"_conn",
"... | Asserts that the connection is open and returns a cursor | [
"Asserts",
"that",
"the",
"connection",
"is",
"open",
"and",
"returns",
"a",
"cursor"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/sessions/sqlite.py#L214-L219 | train | Asserts that the connection is open and returns a cursor | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/sessions/sqlite.py | SQLiteSession._execute | def _execute(self, stmt, *values):
"""
Gets a cursor, executes `stmt` and closes the cursor,
fetching one row afterwards and returning its result.
"""
c = self._cursor()
try:
return c.execute(stmt, values).fetchone()
finally:
c.close() | python | def _execute(self, stmt, *values):
"""
Gets a cursor, executes `stmt` and closes the cursor,
fetching one row afterwards and returning its result.
"""
c = self._cursor()
try:
return c.execute(stmt, values).fetchone()
finally:
c.close() | [
"def",
"_execute",
"(",
"self",
",",
"stmt",
",",
"*",
"values",
")",
":",
"c",
"=",
"self",
".",
"_cursor",
"(",
")",
"try",
":",
"return",
"c",
".",
"execute",
"(",
"stmt",
",",
"values",
")",
".",
"fetchone",
"(",
")",
"finally",
":",
"c",
"... | Gets a cursor, executes `stmt` and closes the cursor,
fetching one row afterwards and returning its result. | [
"Gets",
"a",
"cursor",
"executes",
"stmt",
"and",
"closes",
"the",
"cursor",
"fetching",
"one",
"row",
"afterwards",
"and",
"returning",
"its",
"result",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/sessions/sqlite.py#L221-L230 | train | Executes a statement and returns the first row of the result set. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/sessions/sqlite.py | SQLiteSession.close | def close(self):
"""Closes the connection unless we're working in-memory"""
if self.filename != ':memory:':
if self._conn is not None:
self._conn.commit()
self._conn.close()
self._conn = None | python | def close(self):
"""Closes the connection unless we're working in-memory"""
if self.filename != ':memory:':
if self._conn is not None:
self._conn.commit()
self._conn.close()
self._conn = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
"!=",
"':memory:'",
":",
"if",
"self",
".",
"_conn",
"is",
"not",
"None",
":",
"self",
".",
"_conn",
".",
"commit",
"(",
")",
"self",
".",
"_conn",
".",
"close",
"(",
")",
"sel... | Closes the connection unless we're working in-memory | [
"Closes",
"the",
"connection",
"unless",
"we",
"re",
"working",
"in",
"-",
"memory"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/sessions/sqlite.py#L232-L238 | train | Closes the connection unless we re working in - memory | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/sessions/sqlite.py | SQLiteSession.delete | def delete(self):
"""Deletes the current session file"""
if self.filename == ':memory:':
return True
try:
os.remove(self.filename)
return True
except OSError:
return False | python | def delete(self):
"""Deletes the current session file"""
if self.filename == ':memory:':
return True
try:
os.remove(self.filename)
return True
except OSError:
return False | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
"==",
"':memory:'",
":",
"return",
"True",
"try",
":",
"os",
".",
"remove",
"(",
"self",
".",
"filename",
")",
"return",
"True",
"except",
"OSError",
":",
"return",
"False"
] | Deletes the current session file | [
"Deletes",
"the",
"current",
"session",
"file"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/sessions/sqlite.py#L240-L248 | train | Deletes the current session file | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/sessions/sqlite.py | SQLiteSession.list_sessions | def list_sessions(cls):
"""Lists all the sessions of the users who have ever connected
using this client and never logged out
"""
return [os.path.splitext(os.path.basename(f))[0]
for f in os.listdir('.') if f.endswith(EXTENSION)] | python | def list_sessions(cls):
"""Lists all the sessions of the users who have ever connected
using this client and never logged out
"""
return [os.path.splitext(os.path.basename(f))[0]
for f in os.listdir('.') if f.endswith(EXTENSION)] | [
"def",
"list_sessions",
"(",
"cls",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"f",
")",
")",
"[",
"0",
"]",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"'.'",
")",
"if",
"f",
"... | Lists all the sessions of the users who have ever connected
using this client and never logged out | [
"Lists",
"all",
"the",
"sessions",
"of",
"the",
"users",
"who",
"have",
"ever",
"connected",
"using",
"this",
"client",
"and",
"never",
"logged",
"out"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/sessions/sqlite.py#L251-L256 | train | Lists all the users who have ever connected
using this client and never logged out
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/sessions/sqlite.py | SQLiteSession.process_entities | def process_entities(self, tlo):
"""Processes all the found entities on the given TLObject,
unless .enabled is False.
Returns True if new input entities were added.
"""
if not self.save_entities:
return
rows = self._entities_to_rows(tlo)
if not... | python | def process_entities(self, tlo):
"""Processes all the found entities on the given TLObject,
unless .enabled is False.
Returns True if new input entities were added.
"""
if not self.save_entities:
return
rows = self._entities_to_rows(tlo)
if not... | [
"def",
"process_entities",
"(",
"self",
",",
"tlo",
")",
":",
"if",
"not",
"self",
".",
"save_entities",
":",
"return",
"rows",
"=",
"self",
".",
"_entities_to_rows",
"(",
"tlo",
")",
"if",
"not",
"rows",
":",
"return",
"c",
"=",
"self",
".",
"_cursor"... | Processes all the found entities on the given TLObject,
unless .enabled is False.
Returns True if new input entities were added. | [
"Processes",
"all",
"the",
"found",
"entities",
"on",
"the",
"given",
"TLObject",
"unless",
".",
"enabled",
"is",
"False",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/sessions/sqlite.py#L260-L278 | train | Processes all the found entities on the given TLObject. Returns True if new input entities were added. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/parsers/methods.py | parse_methods | def parse_methods(csv_file, errors_dict):
"""
Parses the input CSV file with columns (method, usability, errors)
and yields `MethodInfo` instances as a result.
"""
with csv_file.open(newline='') as f:
f = csv.reader(f)
next(f, None) # header
for line, (method, usability, err... | python | def parse_methods(csv_file, errors_dict):
"""
Parses the input CSV file with columns (method, usability, errors)
and yields `MethodInfo` instances as a result.
"""
with csv_file.open(newline='') as f:
f = csv.reader(f)
next(f, None) # header
for line, (method, usability, err... | [
"def",
"parse_methods",
"(",
"csv_file",
",",
"errors_dict",
")",
":",
"with",
"csv_file",
".",
"open",
"(",
"newline",
"=",
"''",
")",
"as",
"f",
":",
"f",
"=",
"csv",
".",
"reader",
"(",
"f",
")",
"next",
"(",
"f",
",",
"None",
")",
"# header",
... | Parses the input CSV file with columns (method, usability, errors)
and yields `MethodInfo` instances as a result. | [
"Parses",
"the",
"input",
"CSV",
"file",
"with",
"columns",
"(",
"method",
"usability",
"errors",
")",
"and",
"yields",
"MethodInfo",
"instances",
"as",
"a",
"result",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/parsers/methods.py#L28-L43 | train | Parses the input CSV file with columns method usability and errors and yields MethodInfo instances as a result. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient.connect | async def connect(self):
"""
Connects to Telegram.
"""
await self._sender.connect(self._connection(
self.session.server_address,
self.session.port,
self.session.dc_id,
loop=self._loop,
loggers=self._log,
proxy=self._... | python | async def connect(self):
"""
Connects to Telegram.
"""
await self._sender.connect(self._connection(
self.session.server_address,
self.session.port,
self.session.dc_id,
loop=self._loop,
loggers=self._log,
proxy=self._... | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"await",
"self",
".",
"_sender",
".",
"connect",
"(",
"self",
".",
"_connection",
"(",
"self",
".",
"session",
".",
"server_address",
",",
"self",
".",
"session",
".",
"port",
",",
"self",
".",
"session... | Connects to Telegram. | [
"Connects",
"to",
"Telegram",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L352-L370 | train | Connects to Telegram. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient.disconnect | def disconnect(self):
"""
Disconnects from Telegram.
If the event loop is already running, this method returns a
coroutine that you should await on your own code; otherwise
the loop is ran until said coroutine completes.
"""
if self._loop.is_running():
... | python | def disconnect(self):
"""
Disconnects from Telegram.
If the event loop is already running, this method returns a
coroutine that you should await on your own code; otherwise
the loop is ran until said coroutine completes.
"""
if self._loop.is_running():
... | [
"def",
"disconnect",
"(",
"self",
")",
":",
"if",
"self",
".",
"_loop",
".",
"is_running",
"(",
")",
":",
"return",
"self",
".",
"_disconnect_coro",
"(",
")",
"else",
":",
"self",
".",
"_loop",
".",
"run_until_complete",
"(",
"self",
".",
"_disconnect_co... | Disconnects from Telegram.
If the event loop is already running, this method returns a
coroutine that you should await on your own code; otherwise
the loop is ran until said coroutine completes. | [
"Disconnects",
"from",
"Telegram",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L379-L390 | train | Disconnects from Telegram. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient._disconnect | async def _disconnect(self):
"""
Disconnect only, without closing the session. Used in reconnections
to different data centers, where we don't want to close the session
file; user disconnects however should close it since it means that
their job with the client is complete and we... | python | async def _disconnect(self):
"""
Disconnect only, without closing the session. Used in reconnections
to different data centers, where we don't want to close the session
file; user disconnects however should close it since it means that
their job with the client is complete and we... | [
"async",
"def",
"_disconnect",
"(",
"self",
")",
":",
"await",
"self",
".",
"_sender",
".",
"disconnect",
"(",
")",
"await",
"helpers",
".",
"_cancel",
"(",
"self",
".",
"_log",
"[",
"__name__",
"]",
",",
"updates_handle",
"=",
"self",
".",
"_updates_han... | Disconnect only, without closing the session. Used in reconnections
to different data centers, where we don't want to close the session
file; user disconnects however should close it since it means that
their job with the client is complete and we should clean it up all. | [
"Disconnect",
"only",
"without",
"closing",
"the",
"session",
".",
"Used",
"in",
"reconnections",
"to",
"different",
"data",
"centers",
"where",
"we",
"don",
"t",
"want",
"to",
"close",
"the",
"session",
"file",
";",
"user",
"disconnects",
"however",
"should",... | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L406-L415 | train | Disconnects from the client and cancels all pending updates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient._switch_dc | async def _switch_dc(self, new_dc):
"""
Permanently switches the current connection to the new data center.
"""
self._log[__name__].info('Reconnecting to new data center %s', new_dc)
dc = await self._get_dc(new_dc)
self.session.set_dc(dc.id, dc.ip_address, dc.port)
... | python | async def _switch_dc(self, new_dc):
"""
Permanently switches the current connection to the new data center.
"""
self._log[__name__].info('Reconnecting to new data center %s', new_dc)
dc = await self._get_dc(new_dc)
self.session.set_dc(dc.id, dc.ip_address, dc.port)
... | [
"async",
"def",
"_switch_dc",
"(",
"self",
",",
"new_dc",
")",
":",
"self",
".",
"_log",
"[",
"__name__",
"]",
".",
"info",
"(",
"'Reconnecting to new data center %s'",
",",
"new_dc",
")",
"dc",
"=",
"await",
"self",
".",
"_get_dc",
"(",
"new_dc",
")",
"... | Permanently switches the current connection to the new data center. | [
"Permanently",
"switches",
"the",
"current",
"connection",
"to",
"the",
"new",
"data",
"center",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L417-L431 | train | Switches the current connection to the new data center. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient._auth_key_callback | def _auth_key_callback(self, auth_key):
"""
Callback from the sender whenever it needed to generate a
new authorization key. This means we are not authorized.
"""
self.session.auth_key = auth_key
self.session.save() | python | def _auth_key_callback(self, auth_key):
"""
Callback from the sender whenever it needed to generate a
new authorization key. This means we are not authorized.
"""
self.session.auth_key = auth_key
self.session.save() | [
"def",
"_auth_key_callback",
"(",
"self",
",",
"auth_key",
")",
":",
"self",
".",
"session",
".",
"auth_key",
"=",
"auth_key",
"self",
".",
"session",
".",
"save",
"(",
")"
] | Callback from the sender whenever it needed to generate a
new authorization key. This means we are not authorized. | [
"Callback",
"from",
"the",
"sender",
"whenever",
"it",
"needed",
"to",
"generate",
"a",
"new",
"authorization",
"key",
".",
"This",
"means",
"we",
"are",
"not",
"authorized",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L433-L439 | train | Callback from the sender whenever we need to generate a new authorization key. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient._get_dc | async def _get_dc(self, dc_id, cdn=False):
"""Gets the Data Center (DC) associated to 'dc_id'"""
cls = self.__class__
if not cls._config:
cls._config = await self(functions.help.GetConfigRequest())
if cdn and not self._cdn_config:
cls._cdn_config = await self(fun... | python | async def _get_dc(self, dc_id, cdn=False):
"""Gets the Data Center (DC) associated to 'dc_id'"""
cls = self.__class__
if not cls._config:
cls._config = await self(functions.help.GetConfigRequest())
if cdn and not self._cdn_config:
cls._cdn_config = await self(fun... | [
"async",
"def",
"_get_dc",
"(",
"self",
",",
"dc_id",
",",
"cdn",
"=",
"False",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"not",
"cls",
".",
"_config",
":",
"cls",
".",
"_config",
"=",
"await",
"self",
"(",
"functions",
".",
"help",
"."... | Gets the Data Center (DC) associated to 'dc_id | [
"Gets",
"the",
"Data",
"Center",
"(",
"DC",
")",
"associated",
"to",
"dc_id"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L445-L460 | train | Gets the Data Center ( DC ) associated to dc_id | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient._create_exported_sender | async def _create_exported_sender(self, dc_id):
"""
Creates a new exported `MTProtoSender` for the given `dc_id` and
returns it. This method should be used by `_borrow_exported_sender`.
"""
# Thanks badoualy/kotlogram on /telegram/api/DefaultTelegramClient.kt
# for clearl... | python | async def _create_exported_sender(self, dc_id):
"""
Creates a new exported `MTProtoSender` for the given `dc_id` and
returns it. This method should be used by `_borrow_exported_sender`.
"""
# Thanks badoualy/kotlogram on /telegram/api/DefaultTelegramClient.kt
# for clearl... | [
"async",
"def",
"_create_exported_sender",
"(",
"self",
",",
"dc_id",
")",
":",
"# Thanks badoualy/kotlogram on /telegram/api/DefaultTelegramClient.kt",
"# for clearly showing how to export the authorization",
"dc",
"=",
"await",
"self",
".",
"_get_dc",
"(",
"dc_id",
")",
"# ... | Creates a new exported `MTProtoSender` for the given `dc_id` and
returns it. This method should be used by `_borrow_exported_sender`. | [
"Creates",
"a",
"new",
"exported",
"MTProtoSender",
"for",
"the",
"given",
"dc_id",
"and",
"returns",
"it",
".",
"This",
"method",
"should",
"be",
"used",
"by",
"_borrow_exported_sender",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L462-L490 | train | Creates a new exported MTProtoSender for the given dc_id and returns it. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient._borrow_exported_sender | async def _borrow_exported_sender(self, dc_id):
"""
Borrows a connected `MTProtoSender` for the given `dc_id`.
If it's not cached, creates a new one if it doesn't exist yet,
and imports a freshly exported authorization key for it to be usable.
Once its job is over it should be `... | python | async def _borrow_exported_sender(self, dc_id):
"""
Borrows a connected `MTProtoSender` for the given `dc_id`.
If it's not cached, creates a new one if it doesn't exist yet,
and imports a freshly exported authorization key for it to be usable.
Once its job is over it should be `... | [
"async",
"def",
"_borrow_exported_sender",
"(",
"self",
",",
"dc_id",
")",
":",
"async",
"with",
"self",
".",
"_borrow_sender_lock",
":",
"n",
",",
"sender",
"=",
"self",
".",
"_borrowed_senders",
".",
"get",
"(",
"dc_id",
",",
"(",
"0",
",",
"None",
")"... | Borrows a connected `MTProtoSender` for the given `dc_id`.
If it's not cached, creates a new one if it doesn't exist yet,
and imports a freshly exported authorization key for it to be usable.
Once its job is over it should be `_return_exported_sender`. | [
"Borrows",
"a",
"connected",
"MTProtoSender",
"for",
"the",
"given",
"dc_id",
".",
"If",
"it",
"s",
"not",
"cached",
"creates",
"a",
"new",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"yet",
"and",
"imports",
"a",
"freshly",
"exported",
"authorization",
"key... | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L492-L518 | train | Borrows a connected MTProtoSender for the given dc_id. Returns a new instance of the appropriate class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient._return_exported_sender | async def _return_exported_sender(self, sender):
"""
Returns a borrowed exported sender. If all borrows have
been returned, the sender is cleanly disconnected.
"""
async with self._borrow_sender_lock:
dc_id = sender.dc_id
n, _ = self._borrowed_senders[dc_i... | python | async def _return_exported_sender(self, sender):
"""
Returns a borrowed exported sender. If all borrows have
been returned, the sender is cleanly disconnected.
"""
async with self._borrow_sender_lock:
dc_id = sender.dc_id
n, _ = self._borrowed_senders[dc_i... | [
"async",
"def",
"_return_exported_sender",
"(",
"self",
",",
"sender",
")",
":",
"async",
"with",
"self",
".",
"_borrow_sender_lock",
":",
"dc_id",
"=",
"sender",
".",
"dc_id",
"n",
",",
"_",
"=",
"self",
".",
"_borrowed_senders",
"[",
"dc_id",
"]",
"n",
... | Returns a borrowed exported sender. If all borrows have
been returned, the sender is cleanly disconnected. | [
"Returns",
"a",
"borrowed",
"exported",
"sender",
".",
"If",
"all",
"borrows",
"have",
"been",
"returned",
"the",
"sender",
"is",
"cleanly",
"disconnected",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L520-L533 | train | Returns a borrowed exported sender. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/telegrambaseclient.py | TelegramBaseClient._get_cdn_client | async def _get_cdn_client(self, cdn_redirect):
"""Similar to ._borrow_exported_client, but for CDNs"""
# TODO Implement
raise NotImplementedError
session = self._exported_sessions.get(cdn_redirect.dc_id)
if not session:
dc = await self._get_dc(cdn_redirect.dc_id, cdn=... | python | async def _get_cdn_client(self, cdn_redirect):
"""Similar to ._borrow_exported_client, but for CDNs"""
# TODO Implement
raise NotImplementedError
session = self._exported_sessions.get(cdn_redirect.dc_id)
if not session:
dc = await self._get_dc(cdn_redirect.dc_id, cdn=... | [
"async",
"def",
"_get_cdn_client",
"(",
"self",
",",
"cdn_redirect",
")",
":",
"# TODO Implement",
"raise",
"NotImplementedError",
"session",
"=",
"self",
".",
"_exported_sessions",
".",
"get",
"(",
"cdn_redirect",
".",
"dc_id",
")",
"if",
"not",
"session",
":",... | Similar to ._borrow_exported_client, but for CDNs | [
"Similar",
"to",
".",
"_borrow_exported_client",
"but",
"for",
"CDNs"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/telegrambaseclient.py#L535-L559 | train | Get a new CDN client. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | chunks | def chunks(iterable, size=100):
"""
Turns the given iterable into chunks of the specified size,
which is 100 by default since that's what Telegram uses the most.
"""
it = iter(iterable)
size -= 1
for head in it:
yield itertools.chain([head], itertools.islice(it, size)) | python | def chunks(iterable, size=100):
"""
Turns the given iterable into chunks of the specified size,
which is 100 by default since that's what Telegram uses the most.
"""
it = iter(iterable)
size -= 1
for head in it:
yield itertools.chain([head], itertools.islice(it, size)) | [
"def",
"chunks",
"(",
"iterable",
",",
"size",
"=",
"100",
")",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"size",
"-=",
"1",
"for",
"head",
"in",
"it",
":",
"yield",
"itertools",
".",
"chain",
"(",
"[",
"head",
"]",
",",
"itertools",
".",
"is... | Turns the given iterable into chunks of the specified size,
which is 100 by default since that's what Telegram uses the most. | [
"Turns",
"the",
"given",
"iterable",
"into",
"chunks",
"of",
"the",
"specified",
"size",
"which",
"is",
"100",
"by",
"default",
"since",
"that",
"s",
"what",
"Telegram",
"uses",
"the",
"most",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L73-L81 | train | Turn the given iterable into chunks of the specified size. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_display_name | def get_display_name(entity):
"""
Gets the display name for the given entity, if it's an :tl:`User`,
:tl:`Chat` or :tl:`Channel`. Returns an empty string otherwise.
"""
if isinstance(entity, types.User):
if entity.last_name and entity.first_name:
return '{} {}'.format(entity.firs... | python | def get_display_name(entity):
"""
Gets the display name for the given entity, if it's an :tl:`User`,
:tl:`Chat` or :tl:`Channel`. Returns an empty string otherwise.
"""
if isinstance(entity, types.User):
if entity.last_name and entity.first_name:
return '{} {}'.format(entity.firs... | [
"def",
"get_display_name",
"(",
"entity",
")",
":",
"if",
"isinstance",
"(",
"entity",
",",
"types",
".",
"User",
")",
":",
"if",
"entity",
".",
"last_name",
"and",
"entity",
".",
"first_name",
":",
"return",
"'{} {}'",
".",
"format",
"(",
"entity",
".",... | Gets the display name for the given entity, if it's an :tl:`User`,
:tl:`Chat` or :tl:`Channel`. Returns an empty string otherwise. | [
"Gets",
"the",
"display",
"name",
"for",
"the",
"given",
"entity",
"if",
"it",
"s",
"an",
":",
"tl",
":",
"User",
":",
"tl",
":",
"Chat",
"or",
":",
"tl",
":",
"Channel",
".",
"Returns",
"an",
"empty",
"string",
"otherwise",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L84-L102 | train | Gets the display name for the given entity. Returns an empty string if the given entity is not a user or chat or channel. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_extension | def get_extension(media):
"""Gets the corresponding extension for any Telegram media."""
# Photos are always compressed as .jpg by Telegram
if isinstance(media, (types.UserProfilePhoto,
types.ChatPhoto, types.MessageMediaPhoto)):
return '.jpg'
# Documents will come wi... | python | def get_extension(media):
"""Gets the corresponding extension for any Telegram media."""
# Photos are always compressed as .jpg by Telegram
if isinstance(media, (types.UserProfilePhoto,
types.ChatPhoto, types.MessageMediaPhoto)):
return '.jpg'
# Documents will come wi... | [
"def",
"get_extension",
"(",
"media",
")",
":",
"# Photos are always compressed as .jpg by Telegram",
"if",
"isinstance",
"(",
"media",
",",
"(",
"types",
".",
"UserProfilePhoto",
",",
"types",
".",
"ChatPhoto",
",",
"types",
".",
"MessageMediaPhoto",
")",
")",
":... | Gets the corresponding extension for any Telegram media. | [
"Gets",
"the",
"corresponding",
"extension",
"for",
"any",
"Telegram",
"media",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L105-L124 | train | Gets the corresponding extension for any Telegram media. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_peer | def get_input_peer(entity, allow_self=True, check_hash=True):
"""
Gets the input peer for the given "entity" (user, chat or channel).
A ``TypeError`` is raised if the given entity isn't a supported type
or if ``check_hash is True`` but the entity's ``access_hash is None``.
Note that ``check_hash``... | python | def get_input_peer(entity, allow_self=True, check_hash=True):
"""
Gets the input peer for the given "entity" (user, chat or channel).
A ``TypeError`` is raised if the given entity isn't a supported type
or if ``check_hash is True`` but the entity's ``access_hash is None``.
Note that ``check_hash``... | [
"def",
"get_input_peer",
"(",
"entity",
",",
"allow_self",
"=",
"True",
",",
"check_hash",
"=",
"True",
")",
":",
"try",
":",
"if",
"entity",
".",
"SUBCLASS_OF_ID",
"==",
"0xc91c90b6",
":",
"# crc32(b'InputPeer')",
"return",
"entity",
"except",
"AttributeError",... | Gets the input peer for the given "entity" (user, chat or channel).
A ``TypeError`` is raised if the given entity isn't a supported type
or if ``check_hash is True`` but the entity's ``access_hash is None``.
Note that ``check_hash`` **is ignored** if an input peer is already
passed since in that case ... | [
"Gets",
"the",
"input",
"peer",
"for",
"the",
"given",
"entity",
"(",
"user",
"chat",
"or",
"channel",
")",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L132-L193 | train | Gets the input peer for the given entity. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_channel | def get_input_channel(entity):
"""Similar to :meth:`get_input_peer`, but for :tl:`InputChannel`'s alone."""
try:
if entity.SUBCLASS_OF_ID == 0x40f202fd: # crc32(b'InputChannel')
return entity
except AttributeError:
_raise_cast_fail(entity, 'InputChannel')
if isinstance(enti... | python | def get_input_channel(entity):
"""Similar to :meth:`get_input_peer`, but for :tl:`InputChannel`'s alone."""
try:
if entity.SUBCLASS_OF_ID == 0x40f202fd: # crc32(b'InputChannel')
return entity
except AttributeError:
_raise_cast_fail(entity, 'InputChannel')
if isinstance(enti... | [
"def",
"get_input_channel",
"(",
"entity",
")",
":",
"try",
":",
"if",
"entity",
".",
"SUBCLASS_OF_ID",
"==",
"0x40f202fd",
":",
"# crc32(b'InputChannel')",
"return",
"entity",
"except",
"AttributeError",
":",
"_raise_cast_fail",
"(",
"entity",
",",
"'InputChannel'"... | Similar to :meth:`get_input_peer`, but for :tl:`InputChannel`'s alone. | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
":",
"tl",
":",
"InputChannel",
"s",
"alone",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L196-L210 | train | Similar to get_input_peer but for InputChannel s. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_user | def get_input_user(entity):
"""Similar to :meth:`get_input_peer`, but for :tl:`InputUser`'s alone."""
try:
if entity.SUBCLASS_OF_ID == 0xe669bf46: # crc32(b'InputUser'):
return entity
except AttributeError:
_raise_cast_fail(entity, 'InputUser')
if isinstance(entity, types.U... | python | def get_input_user(entity):
"""Similar to :meth:`get_input_peer`, but for :tl:`InputUser`'s alone."""
try:
if entity.SUBCLASS_OF_ID == 0xe669bf46: # crc32(b'InputUser'):
return entity
except AttributeError:
_raise_cast_fail(entity, 'InputUser')
if isinstance(entity, types.U... | [
"def",
"get_input_user",
"(",
"entity",
")",
":",
"try",
":",
"if",
"entity",
".",
"SUBCLASS_OF_ID",
"==",
"0xe669bf46",
":",
"# crc32(b'InputUser'):",
"return",
"entity",
"except",
"AttributeError",
":",
"_raise_cast_fail",
"(",
"entity",
",",
"'InputUser'",
")",... | Similar to :meth:`get_input_peer`, but for :tl:`InputUser`'s alone. | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
":",
"tl",
":",
"InputUser",
"s",
"alone",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L213-L239 | train | Similar to get_input_peer but for InputUser s. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_dialog | def get_input_dialog(dialog):
"""Similar to :meth:`get_input_peer`, but for dialogs"""
try:
if dialog.SUBCLASS_OF_ID == 0xa21c9795: # crc32(b'InputDialogPeer')
return dialog
if dialog.SUBCLASS_OF_ID == 0xc91c90b6: # crc32(b'InputPeer')
return types.InputDialogPeer(dialo... | python | def get_input_dialog(dialog):
"""Similar to :meth:`get_input_peer`, but for dialogs"""
try:
if dialog.SUBCLASS_OF_ID == 0xa21c9795: # crc32(b'InputDialogPeer')
return dialog
if dialog.SUBCLASS_OF_ID == 0xc91c90b6: # crc32(b'InputPeer')
return types.InputDialogPeer(dialo... | [
"def",
"get_input_dialog",
"(",
"dialog",
")",
":",
"try",
":",
"if",
"dialog",
".",
"SUBCLASS_OF_ID",
"==",
"0xa21c9795",
":",
"# crc32(b'InputDialogPeer')",
"return",
"dialog",
"if",
"dialog",
".",
"SUBCLASS_OF_ID",
"==",
"0xc91c90b6",
":",
"# crc32(b'InputPeer')"... | Similar to :meth:`get_input_peer`, but for dialogs | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"dialogs"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L242-L257 | train | Similar to get_input_peer but for dialogs | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_document | def get_input_document(document):
"""Similar to :meth:`get_input_peer`, but for documents"""
try:
if document.SUBCLASS_OF_ID == 0xf33fdb68: # crc32(b'InputDocument'):
return document
except AttributeError:
_raise_cast_fail(document, 'InputDocument')
if isinstance(document, ... | python | def get_input_document(document):
"""Similar to :meth:`get_input_peer`, but for documents"""
try:
if document.SUBCLASS_OF_ID == 0xf33fdb68: # crc32(b'InputDocument'):
return document
except AttributeError:
_raise_cast_fail(document, 'InputDocument')
if isinstance(document, ... | [
"def",
"get_input_document",
"(",
"document",
")",
":",
"try",
":",
"if",
"document",
".",
"SUBCLASS_OF_ID",
"==",
"0xf33fdb68",
":",
"# crc32(b'InputDocument'):",
"return",
"document",
"except",
"AttributeError",
":",
"_raise_cast_fail",
"(",
"document",
",",
"'Inp... | Similar to :meth:`get_input_peer`, but for documents | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"documents"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L260-L282 | train | Similar to get_input_peer but for documents | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_photo | def get_input_photo(photo):
"""Similar to :meth:`get_input_peer`, but for photos"""
try:
if photo.SUBCLASS_OF_ID == 0x846363e0: # crc32(b'InputPhoto'):
return photo
except AttributeError:
_raise_cast_fail(photo, 'InputPhoto')
if isinstance(photo, types.photos.Photo):
... | python | def get_input_photo(photo):
"""Similar to :meth:`get_input_peer`, but for photos"""
try:
if photo.SUBCLASS_OF_ID == 0x846363e0: # crc32(b'InputPhoto'):
return photo
except AttributeError:
_raise_cast_fail(photo, 'InputPhoto')
if isinstance(photo, types.photos.Photo):
... | [
"def",
"get_input_photo",
"(",
"photo",
")",
":",
"try",
":",
"if",
"photo",
".",
"SUBCLASS_OF_ID",
"==",
"0x846363e0",
":",
"# crc32(b'InputPhoto'):",
"return",
"photo",
"except",
"AttributeError",
":",
"_raise_cast_fail",
"(",
"photo",
",",
"'InputPhoto'",
")",
... | Similar to :meth:`get_input_peer`, but for photos | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"photos"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L285-L316 | train | Similar to get_input_peer but for photos | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_chat_photo | def get_input_chat_photo(photo):
"""Similar to :meth:`get_input_peer`, but for chat photos"""
try:
if photo.SUBCLASS_OF_ID == 0xd4eb2d74: # crc32(b'InputChatPhoto')
return photo
elif photo.SUBCLASS_OF_ID == 0xe7655f1f: # crc32(b'InputFile'):
return types.InputChatUpload... | python | def get_input_chat_photo(photo):
"""Similar to :meth:`get_input_peer`, but for chat photos"""
try:
if photo.SUBCLASS_OF_ID == 0xd4eb2d74: # crc32(b'InputChatPhoto')
return photo
elif photo.SUBCLASS_OF_ID == 0xe7655f1f: # crc32(b'InputFile'):
return types.InputChatUpload... | [
"def",
"get_input_chat_photo",
"(",
"photo",
")",
":",
"try",
":",
"if",
"photo",
".",
"SUBCLASS_OF_ID",
"==",
"0xd4eb2d74",
":",
"# crc32(b'InputChatPhoto')",
"return",
"photo",
"elif",
"photo",
".",
"SUBCLASS_OF_ID",
"==",
"0xe7655f1f",
":",
"# crc32(b'InputFile')... | Similar to :meth:`get_input_peer`, but for chat photos | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"chat",
"photos"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L319-L335 | train | Similar to get_input_peer but for chat photos | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_geo | def get_input_geo(geo):
"""Similar to :meth:`get_input_peer`, but for geo points"""
try:
if geo.SUBCLASS_OF_ID == 0x430d225: # crc32(b'InputGeoPoint'):
return geo
except AttributeError:
_raise_cast_fail(geo, 'InputGeoPoint')
if isinstance(geo, types.GeoPoint):
retur... | python | def get_input_geo(geo):
"""Similar to :meth:`get_input_peer`, but for geo points"""
try:
if geo.SUBCLASS_OF_ID == 0x430d225: # crc32(b'InputGeoPoint'):
return geo
except AttributeError:
_raise_cast_fail(geo, 'InputGeoPoint')
if isinstance(geo, types.GeoPoint):
retur... | [
"def",
"get_input_geo",
"(",
"geo",
")",
":",
"try",
":",
"if",
"geo",
".",
"SUBCLASS_OF_ID",
"==",
"0x430d225",
":",
"# crc32(b'InputGeoPoint'):",
"return",
"geo",
"except",
"AttributeError",
":",
"_raise_cast_fail",
"(",
"geo",
",",
"'InputGeoPoint'",
")",
"if... | Similar to :meth:`get_input_peer`, but for geo points | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"geo",
"points"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L338-L358 | train | Similar to get_input_peer but for GeoPoints | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_media | def get_input_media(
media, *,
is_photo=False, attributes=None, force_document=False,
voice_note=False, video_note=False, supports_streaming=False
):
"""
Similar to :meth:`get_input_peer`, but for media.
If the media is :tl:`InputFile` and ``is_photo`` is known to be ``True``,
i... | python | def get_input_media(
media, *,
is_photo=False, attributes=None, force_document=False,
voice_note=False, video_note=False, supports_streaming=False
):
"""
Similar to :meth:`get_input_peer`, but for media.
If the media is :tl:`InputFile` and ``is_photo`` is known to be ``True``,
i... | [
"def",
"get_input_media",
"(",
"media",
",",
"*",
",",
"is_photo",
"=",
"False",
",",
"attributes",
"=",
"None",
",",
"force_document",
"=",
"False",
",",
"voice_note",
"=",
"False",
",",
"video_note",
"=",
"False",
",",
"supports_streaming",
"=",
"False",
... | Similar to :meth:`get_input_peer`, but for media.
If the media is :tl:`InputFile` and ``is_photo`` is known to be ``True``,
it will be treated as an :tl:`InputMediaUploadedPhoto`. Else, the rest
of parameters will indicate how to treat it. | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"media",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L361-L454 | train | Returns a new InputMedia object for the given media. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_message | def get_input_message(message):
"""Similar to :meth:`get_input_peer`, but for input messages."""
try:
if isinstance(message, int): # This case is really common too
return types.InputMessageID(message)
elif message.SUBCLASS_OF_ID == 0x54b6bcc5: # crc32(b'InputMessage'):
... | python | def get_input_message(message):
"""Similar to :meth:`get_input_peer`, but for input messages."""
try:
if isinstance(message, int): # This case is really common too
return types.InputMessageID(message)
elif message.SUBCLASS_OF_ID == 0x54b6bcc5: # crc32(b'InputMessage'):
... | [
"def",
"get_input_message",
"(",
"message",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"message",
",",
"int",
")",
":",
"# This case is really common too",
"return",
"types",
".",
"InputMessageID",
"(",
"message",
")",
"elif",
"message",
".",
"SUBCLASS_OF_ID... | Similar to :meth:`get_input_peer`, but for input messages. | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"input",
"messages",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L457-L469 | train | Similar to get_input_peer but for input messages. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_message_id | def get_message_id(message):
"""Similar to :meth:`get_input_peer`, but for message IDs."""
if message is None:
return None
if isinstance(message, int):
return message
try:
if message.SUBCLASS_OF_ID == 0x790009e3:
# hex(crc32(b'Message')) = 0x790009e3
ret... | python | def get_message_id(message):
"""Similar to :meth:`get_input_peer`, but for message IDs."""
if message is None:
return None
if isinstance(message, int):
return message
try:
if message.SUBCLASS_OF_ID == 0x790009e3:
# hex(crc32(b'Message')) = 0x790009e3
ret... | [
"def",
"get_message_id",
"(",
"message",
")",
":",
"if",
"message",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"message",
",",
"int",
")",
":",
"return",
"message",
"try",
":",
"if",
"message",
".",
"SUBCLASS_OF_ID",
"==",
"0x790009e3",
... | Similar to :meth:`get_input_peer`, but for message IDs. | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"message",
"IDs",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L472-L487 | train | Similar to get_input_peer but for message IDs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_attributes | def get_attributes(file, *, attributes=None, mime_type=None,
force_document=False, voice_note=False, video_note=False,
supports_streaming=False):
"""
Get a list of attributes for the given file and
the mime type as a tuple ([attribute], mime_type).
"""
# Note: `... | python | def get_attributes(file, *, attributes=None, mime_type=None,
force_document=False, voice_note=False, video_note=False,
supports_streaming=False):
"""
Get a list of attributes for the given file and
the mime type as a tuple ([attribute], mime_type).
"""
# Note: `... | [
"def",
"get_attributes",
"(",
"file",
",",
"*",
",",
"attributes",
"=",
"None",
",",
"mime_type",
"=",
"None",
",",
"force_document",
"=",
"False",
",",
"voice_note",
"=",
"False",
",",
"video_note",
"=",
"False",
",",
"supports_streaming",
"=",
"False",
"... | Get a list of attributes for the given file and
the mime type as a tuple ([attribute], mime_type). | [
"Get",
"a",
"list",
"of",
"attributes",
"for",
"the",
"given",
"file",
"and",
"the",
"mime",
"type",
"as",
"a",
"tuple",
"(",
"[",
"attribute",
"]",
"mime_type",
")",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L503-L568 | train | Get a list of attributes for the given file and mime type. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | sanitize_parse_mode | def sanitize_parse_mode(mode):
"""
Converts the given parse mode into an object with
``parse`` and ``unparse`` callable properties.
"""
if not mode:
return None
if callable(mode):
class CustomMode:
@staticmethod
def unparse(text, entities):
... | python | def sanitize_parse_mode(mode):
"""
Converts the given parse mode into an object with
``parse`` and ``unparse`` callable properties.
"""
if not mode:
return None
if callable(mode):
class CustomMode:
@staticmethod
def unparse(text, entities):
... | [
"def",
"sanitize_parse_mode",
"(",
"mode",
")",
":",
"if",
"not",
"mode",
":",
"return",
"None",
"if",
"callable",
"(",
"mode",
")",
":",
"class",
"CustomMode",
":",
"@",
"staticmethod",
"def",
"unparse",
"(",
"text",
",",
"entities",
")",
":",
"raise",
... | Converts the given parse mode into an object with
``parse`` and ``unparse`` callable properties. | [
"Converts",
"the",
"given",
"parse",
"mode",
"into",
"an",
"object",
"with",
"parse",
"and",
"unparse",
"callable",
"properties",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L571-L601 | train | Sanitize the given parse mode into an object with the appropriate parse and unparse callable properties. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_input_location | def get_input_location(location):
"""
Similar to :meth:`get_input_peer`, but for input messages.
Note that this returns a tuple ``(dc_id, location)``, the
``dc_id`` being present if known.
"""
try:
if location.SUBCLASS_OF_ID == 0x1523d462:
return None, location # crc32(b'In... | python | def get_input_location(location):
"""
Similar to :meth:`get_input_peer`, but for input messages.
Note that this returns a tuple ``(dc_id, location)``, the
``dc_id`` being present if known.
"""
try:
if location.SUBCLASS_OF_ID == 0x1523d462:
return None, location # crc32(b'In... | [
"def",
"get_input_location",
"(",
"location",
")",
":",
"try",
":",
"if",
"location",
".",
"SUBCLASS_OF_ID",
"==",
"0x1523d462",
":",
"return",
"None",
",",
"location",
"# crc32(b'InputFileLocation'):",
"except",
"AttributeError",
":",
"_raise_cast_fail",
"(",
"loca... | Similar to :meth:`get_input_peer`, but for input messages.
Note that this returns a tuple ``(dc_id, location)``, the
``dc_id`` being present if known. | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
"input",
"messages",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L604-L643 | train | Returns a tuple of dc_id and location for input messages. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | _get_extension | def _get_extension(file):
"""
Gets the extension for the given file, which can be either a
str or an ``open()``'ed file (which has a ``.name`` attribute).
"""
if isinstance(file, str):
return os.path.splitext(file)[-1]
elif isinstance(file, bytes):
kind = imghdr.what(io.BytesIO(f... | python | def _get_extension(file):
"""
Gets the extension for the given file, which can be either a
str or an ``open()``'ed file (which has a ``.name`` attribute).
"""
if isinstance(file, str):
return os.path.splitext(file)[-1]
elif isinstance(file, bytes):
kind = imghdr.what(io.BytesIO(f... | [
"def",
"_get_extension",
"(",
"file",
")",
":",
"if",
"isinstance",
"(",
"file",
",",
"str",
")",
":",
"return",
"os",
".",
"path",
".",
"splitext",
"(",
"file",
")",
"[",
"-",
"1",
"]",
"elif",
"isinstance",
"(",
"file",
",",
"bytes",
")",
":",
... | Gets the extension for the given file, which can be either a
str or an ``open()``'ed file (which has a ``.name`` attribute). | [
"Gets",
"the",
"extension",
"for",
"the",
"given",
"file",
"which",
"can",
"be",
"either",
"a",
"str",
"or",
"an",
"open",
"()",
"ed",
"file",
"(",
"which",
"has",
"a",
".",
"name",
"attribute",
")",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L646-L663 | train | Gets the extension for the given file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | is_image | def is_image(file):
"""
Returns ``True`` if the file extension looks like an image file to Telegram.
"""
match = re.match(r'\.(png|jpe?g)', _get_extension(file), re.IGNORECASE)
if match:
return True
else:
return isinstance(resolve_bot_file_id(file), types.Photo) | python | def is_image(file):
"""
Returns ``True`` if the file extension looks like an image file to Telegram.
"""
match = re.match(r'\.(png|jpe?g)', _get_extension(file), re.IGNORECASE)
if match:
return True
else:
return isinstance(resolve_bot_file_id(file), types.Photo) | [
"def",
"is_image",
"(",
"file",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'\\.(png|jpe?g)'",
",",
"_get_extension",
"(",
"file",
")",
",",
"re",
".",
"IGNORECASE",
")",
"if",
"match",
":",
"return",
"True",
"else",
":",
"return",
"isinstance",
... | Returns ``True`` if the file extension looks like an image file to Telegram. | [
"Returns",
"True",
"if",
"the",
"file",
"extension",
"looks",
"like",
"an",
"image",
"file",
"to",
"Telegram",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L666-L674 | train | Returns True if the file extension looks like an image file to Telegram. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | parse_phone | def parse_phone(phone):
"""Parses the given phone, or returns ``None`` if it's invalid."""
if isinstance(phone, int):
return str(phone)
else:
phone = re.sub(r'[+()\s-]', '', str(phone))
if phone.isdigit():
return phone | python | def parse_phone(phone):
"""Parses the given phone, or returns ``None`` if it's invalid."""
if isinstance(phone, int):
return str(phone)
else:
phone = re.sub(r'[+()\s-]', '', str(phone))
if phone.isdigit():
return phone | [
"def",
"parse_phone",
"(",
"phone",
")",
":",
"if",
"isinstance",
"(",
"phone",
",",
"int",
")",
":",
"return",
"str",
"(",
"phone",
")",
"else",
":",
"phone",
"=",
"re",
".",
"sub",
"(",
"r'[+()\\s-]'",
",",
"''",
",",
"str",
"(",
"phone",
")",
... | Parses the given phone, or returns ``None`` if it's invalid. | [
"Parses",
"the",
"given",
"phone",
"or",
"returns",
"None",
"if",
"it",
"s",
"invalid",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L707-L714 | train | Parses the given phone number or returns None if it s invalid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | parse_username | def parse_username(username):
"""
Parses the given username or channel access hash, given
a string, username or URL. Returns a tuple consisting of
both the stripped, lowercase username and whether it is
a joinchat/ hash (in which case is not lowercase'd).
Returns ``(None, False)`` if the ``user... | python | def parse_username(username):
"""
Parses the given username or channel access hash, given
a string, username or URL. Returns a tuple consisting of
both the stripped, lowercase username and whether it is
a joinchat/ hash (in which case is not lowercase'd).
Returns ``(None, False)`` if the ``user... | [
"def",
"parse_username",
"(",
"username",
")",
":",
"username",
"=",
"username",
".",
"strip",
"(",
")",
"m",
"=",
"USERNAME_RE",
".",
"match",
"(",
"username",
")",
"or",
"TG_JOIN_RE",
".",
"match",
"(",
"username",
")",
"if",
"m",
":",
"username",
"=... | Parses the given username or channel access hash, given
a string, username or URL. Returns a tuple consisting of
both the stripped, lowercase username and whether it is
a joinchat/ hash (in which case is not lowercase'd).
Returns ``(None, False)`` if the ``username`` or link is not valid. | [
"Parses",
"the",
"given",
"username",
"or",
"channel",
"access",
"hash",
"given",
"a",
"string",
"username",
"or",
"URL",
".",
"Returns",
"a",
"tuple",
"consisting",
"of",
"both",
"the",
"stripped",
"lowercase",
"username",
"and",
"whether",
"it",
"is",
"a",... | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L717-L739 | train | Parses the given username or channel access hash given
a string username or URL. Returns a tuple consisting of the stripped lowercase username whether it is a joinchat or hash. Returns None if the given username or link is not valid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_inner_text | def get_inner_text(text, entities):
"""
Gets the inner text that's surrounded by the given entities.
For instance: text = 'hey!', entity = MessageEntityBold(2, 2) -> 'y!'.
:param text: the original text.
:param entities: the entity or entities that must be matched.
:return: a single result ... | python | def get_inner_text(text, entities):
"""
Gets the inner text that's surrounded by the given entities.
For instance: text = 'hey!', entity = MessageEntityBold(2, 2) -> 'y!'.
:param text: the original text.
:param entities: the entity or entities that must be matched.
:return: a single result ... | [
"def",
"get_inner_text",
"(",
"text",
",",
"entities",
")",
":",
"text",
"=",
"add_surrogate",
"(",
"text",
")",
"result",
"=",
"[",
"]",
"for",
"e",
"in",
"entities",
":",
"start",
"=",
"e",
".",
"offset",
"end",
"=",
"e",
".",
"offset",
"+",
"e",... | Gets the inner text that's surrounded by the given entities.
For instance: text = 'hey!', entity = MessageEntityBold(2, 2) -> 'y!'.
:param text: the original text.
:param entities: the entity or entities that must be matched.
:return: a single result or a list of the text surrounded by the entities... | [
"Gets",
"the",
"inner",
"text",
"that",
"s",
"surrounded",
"by",
"the",
"given",
"entities",
".",
"For",
"instance",
":",
"text",
"=",
"hey!",
"entity",
"=",
"MessageEntityBold",
"(",
"2",
"2",
")",
"-",
">",
"y!",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L742-L758 | train | Gets the inner text that s surrounded by the given entities. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | get_peer_id | def get_peer_id(peer, add_mark=True):
"""
Finds the ID of the given peer, and converts it to the "bot api" format
so it the peer can be identified back. User ID is left unmodified,
chat ID is negated, and channel ID is prefixed with -100.
The original ID and the peer type class can be returned with... | python | def get_peer_id(peer, add_mark=True):
"""
Finds the ID of the given peer, and converts it to the "bot api" format
so it the peer can be identified back. User ID is left unmodified,
chat ID is negated, and channel ID is prefixed with -100.
The original ID and the peer type class can be returned with... | [
"def",
"get_peer_id",
"(",
"peer",
",",
"add_mark",
"=",
"True",
")",
":",
"# First we assert it's a Peer TLObject, or early return for integers",
"if",
"isinstance",
"(",
"peer",
",",
"int",
")",
":",
"return",
"peer",
"if",
"add_mark",
"else",
"resolve_id",
"(",
... | Finds the ID of the given peer, and converts it to the "bot api" format
so it the peer can be identified back. User ID is left unmodified,
chat ID is negated, and channel ID is prefixed with -100.
The original ID and the peer type class can be returned with
a call to :meth:`resolve_id(marked_id)`. | [
"Finds",
"the",
"ID",
"of",
"the",
"given",
"peer",
"and",
"converts",
"it",
"to",
"the",
"bot",
"api",
"format",
"so",
"it",
"the",
"peer",
"can",
"be",
"identified",
"back",
".",
"User",
"ID",
"is",
"left",
"unmodified",
"chat",
"ID",
"is",
"negated"... | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L791-L832 | train | Returns the ID of the given peer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | resolve_id | def resolve_id(marked_id):
"""Given a marked ID, returns the original ID and its :tl:`Peer` type."""
if marked_id >= 0:
return marked_id, types.PeerUser
# There have been report of chat IDs being 10000xyz, which means their
# marked version is -10000xyz, which in turn looks like a channel but
... | python | def resolve_id(marked_id):
"""Given a marked ID, returns the original ID and its :tl:`Peer` type."""
if marked_id >= 0:
return marked_id, types.PeerUser
# There have been report of chat IDs being 10000xyz, which means their
# marked version is -10000xyz, which in turn looks like a channel but
... | [
"def",
"resolve_id",
"(",
"marked_id",
")",
":",
"if",
"marked_id",
">=",
"0",
":",
"return",
"marked_id",
",",
"types",
".",
"PeerUser",
"# There have been report of chat IDs being 10000xyz, which means their",
"# marked version is -10000xyz, which in turn looks like a channel b... | Given a marked ID, returns the original ID and its :tl:`Peer` type. | [
"Given",
"a",
"marked",
"ID",
"returns",
"the",
"original",
"ID",
"and",
"its",
":",
"tl",
":",
"Peer",
"type",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L835-L848 | train | Given a marked ID returns the original ID and its peer type. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | _rle_decode | def _rle_decode(data):
"""
Decodes run-length-encoded `data`.
"""
if not data:
return data
new = b''
last = b''
for cur in data:
if last == b'\0':
new += last * cur
last = b''
else:
new += last
last = bytes([cur])
... | python | def _rle_decode(data):
"""
Decodes run-length-encoded `data`.
"""
if not data:
return data
new = b''
last = b''
for cur in data:
if last == b'\0':
new += last * cur
last = b''
else:
new += last
last = bytes([cur])
... | [
"def",
"_rle_decode",
"(",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"data",
"new",
"=",
"b''",
"last",
"=",
"b''",
"for",
"cur",
"in",
"data",
":",
"if",
"last",
"==",
"b'\\0'",
":",
"new",
"+=",
"last",
"*",
"cur",
"last",
"=",
"b''... | Decodes run-length-encoded `data`. | [
"Decodes",
"run",
"-",
"length",
"-",
"encoded",
"data",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L851-L868 | train | Decode a run - length - encoded byte string into a single byte string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | _decode_telegram_base64 | def _decode_telegram_base64(string):
"""
Decodes an url-safe base64-encoded string into its bytes
by first adding the stripped necessary padding characters.
This is the way Telegram shares binary data as strings,
such as Bot API-style file IDs or invite links.
Returns ``None`` if the input str... | python | def _decode_telegram_base64(string):
"""
Decodes an url-safe base64-encoded string into its bytes
by first adding the stripped necessary padding characters.
This is the way Telegram shares binary data as strings,
such as Bot API-style file IDs or invite links.
Returns ``None`` if the input str... | [
"def",
"_decode_telegram_base64",
"(",
"string",
")",
":",
"try",
":",
"return",
"base64",
".",
"urlsafe_b64decode",
"(",
"string",
"+",
"'='",
"*",
"(",
"len",
"(",
"string",
")",
"%",
"4",
")",
")",
"except",
"(",
"binascii",
".",
"Error",
",",
"Valu... | Decodes an url-safe base64-encoded string into its bytes
by first adding the stripped necessary padding characters.
This is the way Telegram shares binary data as strings,
such as Bot API-style file IDs or invite links.
Returns ``None`` if the input string was not valid. | [
"Decodes",
"an",
"url",
"-",
"safe",
"base64",
"-",
"encoded",
"string",
"into",
"its",
"bytes",
"by",
"first",
"adding",
"the",
"stripped",
"necessary",
"padding",
"characters",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L886-L899 | train | Decode a Telegram base64 - encoded string into its bytes
. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | _encode_telegram_base64 | def _encode_telegram_base64(string):
"""
Inverse for `_decode_telegram_base64`.
"""
try:
return base64.urlsafe_b64encode(string).rstrip(b'=').decode('ascii')
except (binascii.Error, ValueError, TypeError):
return None | python | def _encode_telegram_base64(string):
"""
Inverse for `_decode_telegram_base64`.
"""
try:
return base64.urlsafe_b64encode(string).rstrip(b'=').decode('ascii')
except (binascii.Error, ValueError, TypeError):
return None | [
"def",
"_encode_telegram_base64",
"(",
"string",
")",
":",
"try",
":",
"return",
"base64",
".",
"urlsafe_b64encode",
"(",
"string",
")",
".",
"rstrip",
"(",
"b'='",
")",
".",
"decode",
"(",
"'ascii'",
")",
"except",
"(",
"binascii",
".",
"Error",
",",
"V... | Inverse for `_decode_telegram_base64`. | [
"Inverse",
"for",
"_decode_telegram_base64",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L902-L909 | train | Decodes a Telegram base64 string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | resolve_bot_file_id | def resolve_bot_file_id(file_id):
"""
Given a Bot API-style `file_id`, returns the media it represents.
If the `file_id` is not valid, ``None`` is returned instead.
Note that the `file_id` does not have information such as image
dimensions or file size, so these will be zero if present.
For th... | python | def resolve_bot_file_id(file_id):
"""
Given a Bot API-style `file_id`, returns the media it represents.
If the `file_id` is not valid, ``None`` is returned instead.
Note that the `file_id` does not have information such as image
dimensions or file size, so these will be zero if present.
For th... | [
"def",
"resolve_bot_file_id",
"(",
"file_id",
")",
":",
"data",
"=",
"_rle_decode",
"(",
"_decode_telegram_base64",
"(",
"file_id",
")",
")",
"if",
"not",
"data",
"or",
"data",
"[",
"-",
"1",
"]",
"==",
"b'\\x02'",
":",
"return",
"None",
"data",
"=",
"da... | Given a Bot API-style `file_id`, returns the media it represents.
If the `file_id` is not valid, ``None`` is returned instead.
Note that the `file_id` does not have information such as image
dimensions or file size, so these will be zero if present.
For thumbnails, the photo ID and hash will always be... | [
"Given",
"a",
"Bot",
"API",
"-",
"style",
"file_id",
"returns",
"the",
"media",
"it",
"represents",
".",
"If",
"the",
"file_id",
"is",
"not",
"valid",
"None",
"is",
"returned",
"instead",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L912-L998 | train | Given a Bot API - style file_id returns the media it represents. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | pack_bot_file_id | def pack_bot_file_id(file):
"""
Inverse operation for `resolve_bot_file_id`.
The only parameters this method will accept are :tl:`Document` and
:tl:`Photo`, and it will return a variable-length ``file_id`` string.
If an invalid parameter is given, it will ``return None``.
"""
if isinstance... | python | def pack_bot_file_id(file):
"""
Inverse operation for `resolve_bot_file_id`.
The only parameters this method will accept are :tl:`Document` and
:tl:`Photo`, and it will return a variable-length ``file_id`` string.
If an invalid parameter is given, it will ``return None``.
"""
if isinstance... | [
"def",
"pack_bot_file_id",
"(",
"file",
")",
":",
"if",
"isinstance",
"(",
"file",
",",
"types",
".",
"MessageMediaDocument",
")",
":",
"file",
"=",
"file",
".",
"document",
"elif",
"isinstance",
"(",
"file",
",",
"types",
".",
"MessageMediaPhoto",
")",
":... | Inverse operation for `resolve_bot_file_id`.
The only parameters this method will accept are :tl:`Document` and
:tl:`Photo`, and it will return a variable-length ``file_id`` string.
If an invalid parameter is given, it will ``return None``. | [
"Inverse",
"operation",
"for",
"resolve_bot_file_id",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L1001-L1046 | train | Packs a bot file id into a base64 string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | resolve_invite_link | def resolve_invite_link(link):
"""
Resolves the given invite link. Returns a tuple of
``(link creator user id, global chat id, random int)``.
Note that for broadcast channels, the link creator
user ID will be zero to protect their identity.
Normal chats and megagroup channels will have such ID.... | python | def resolve_invite_link(link):
"""
Resolves the given invite link. Returns a tuple of
``(link creator user id, global chat id, random int)``.
Note that for broadcast channels, the link creator
user ID will be zero to protect their identity.
Normal chats and megagroup channels will have such ID.... | [
"def",
"resolve_invite_link",
"(",
"link",
")",
":",
"link_hash",
",",
"is_link",
"=",
"parse_username",
"(",
"link",
")",
"if",
"not",
"is_link",
":",
"# Perhaps the user passed the link hash directly",
"link_hash",
"=",
"link",
"try",
":",
"return",
"struct",
".... | Resolves the given invite link. Returns a tuple of
``(link creator user id, global chat id, random int)``.
Note that for broadcast channels, the link creator
user ID will be zero to protect their identity.
Normal chats and megagroup channels will have such ID.
Note that the chat ID may not be accu... | [
"Resolves",
"the",
"given",
"invite",
"link",
".",
"Returns",
"a",
"tuple",
"of",
"(",
"link",
"creator",
"user",
"id",
"global",
"chat",
"id",
"random",
"int",
")",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L1049-L1071 | train | Resolves the given invite link. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | resolve_inline_message_id | def resolve_inline_message_id(inline_msg_id):
"""
Resolves an inline message ID. Returns a tuple of
``(message id, peer, dc id, access hash)``
The ``peer`` may either be a :tl:`PeerUser` referencing
the user who sent the message via the bot in a private
conversation or small group chat, or a :t... | python | def resolve_inline_message_id(inline_msg_id):
"""
Resolves an inline message ID. Returns a tuple of
``(message id, peer, dc id, access hash)``
The ``peer`` may either be a :tl:`PeerUser` referencing
the user who sent the message via the bot in a private
conversation or small group chat, or a :t... | [
"def",
"resolve_inline_message_id",
"(",
"inline_msg_id",
")",
":",
"try",
":",
"dc_id",
",",
"message_id",
",",
"pid",
",",
"access_hash",
"=",
"struct",
".",
"unpack",
"(",
"'<iiiq'",
",",
"_decode_telegram_base64",
"(",
"inline_msg_id",
")",
")",
"peer",
"=... | Resolves an inline message ID. Returns a tuple of
``(message id, peer, dc id, access hash)``
The ``peer`` may either be a :tl:`PeerUser` referencing
the user who sent the message via the bot in a private
conversation or small group chat, or a :tl:`PeerChannel`
if the message was sent in a channel.
... | [
"Resolves",
"an",
"inline",
"message",
"ID",
".",
"Returns",
"a",
"tuple",
"of",
"(",
"message",
"id",
"peer",
"dc",
"id",
"access",
"hash",
")"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L1074-L1092 | train | Resolves an inline message ID. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/utils.py | stripped_photo_to_jpg | def stripped_photo_to_jpg(stripped):
"""
Adds the JPG header and footer to a stripped image.
Ported from https://github.com/telegramdesktop/tdesktop/blob/bec39d89e19670eb436dc794a8f20b657cb87c71/Telegram/SourceFiles/ui/image/image.cpp#L225
"""
if len(stripped) < 3 or stripped[0] != 1:
retur... | python | def stripped_photo_to_jpg(stripped):
"""
Adds the JPG header and footer to a stripped image.
Ported from https://github.com/telegramdesktop/tdesktop/blob/bec39d89e19670eb436dc794a8f20b657cb87c71/Telegram/SourceFiles/ui/image/image.cpp#L225
"""
if len(stripped) < 3 or stripped[0] != 1:
retur... | [
"def",
"stripped_photo_to_jpg",
"(",
"stripped",
")",
":",
"if",
"len",
"(",
"stripped",
")",
"<",
"3",
"or",
"stripped",
"[",
"0",
"]",
"!=",
"1",
":",
"return",
"stripped",
"header",
"=",
"bytearray",
"(",
"b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\... | Adds the JPG header and footer to a stripped image.
Ported from https://github.com/telegramdesktop/tdesktop/blob/bec39d89e19670eb436dc794a8f20b657cb87c71/Telegram/SourceFiles/ui/image/image.cpp#L225 | [
"Adds",
"the",
"JPG",
"header",
"and",
"footer",
"to",
"a",
"stripped",
"image",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L1128-L1141 | train | Convert a stripped photo to a JPG file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/network/mtprotoplainsender.py | MTProtoPlainSender.send | async def send(self, request):
"""
Sends and receives the result for the given request.
"""
body = bytes(request)
msg_id = self._state._get_new_msg_id()
await self._connection.send(
struct.pack('<qqi', 0, msg_id, len(body)) + body
)
body = awa... | python | async def send(self, request):
"""
Sends and receives the result for the given request.
"""
body = bytes(request)
msg_id = self._state._get_new_msg_id()
await self._connection.send(
struct.pack('<qqi', 0, msg_id, len(body)) + body
)
body = awa... | [
"async",
"def",
"send",
"(",
"self",
",",
"request",
")",
":",
"body",
"=",
"bytes",
"(",
"request",
")",
"msg_id",
"=",
"self",
".",
"_state",
".",
"_get_new_msg_id",
"(",
")",
"await",
"self",
".",
"_connection",
".",
"send",
"(",
"struct",
".",
"p... | Sends and receives the result for the given request. | [
"Sends",
"and",
"receives",
"the",
"result",
"for",
"the",
"given",
"request",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/mtprotoplainsender.py#L26-L56 | train | Sends and receives the result for the given request. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter._rel | def _rel(self, path):
"""
Get the relative path for the given path from the current
file by working around https://bugs.python.org/issue20012.
"""
return os.path.relpath(
str(path), self._parent).replace(os.path.sep, '/') | python | def _rel(self, path):
"""
Get the relative path for the given path from the current
file by working around https://bugs.python.org/issue20012.
"""
return os.path.relpath(
str(path), self._parent).replace(os.path.sep, '/') | [
"def",
"_rel",
"(",
"self",
",",
"path",
")",
":",
"return",
"os",
".",
"path",
".",
"relpath",
"(",
"str",
"(",
"path",
")",
",",
"self",
".",
"_parent",
")",
".",
"replace",
"(",
"os",
".",
"path",
".",
"sep",
",",
"'/'",
")"
] | Get the relative path for the given path from the current
file by working around https://bugs.python.org/issue20012. | [
"Get",
"the",
"relative",
"path",
"for",
"the",
"given",
"path",
"from",
"the",
"current",
"file",
"by",
"working",
"around",
"https",
":",
"//",
"bugs",
".",
"python",
".",
"org",
"/",
"issue20012",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L33-L39 | train | Get the relative path for the given path from the current
file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.write_head | def write_head(self, title, css_path, default_css):
"""Writes the head part for the generated document,
with the given title and CSS
"""
self.title = title
self.write(
'''<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=... | python | def write_head(self, title, css_path, default_css):
"""Writes the head part for the generated document,
with the given title and CSS
"""
self.title = title
self.write(
'''<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=... | [
"def",
"write_head",
"(",
"self",
",",
"title",
",",
"css_path",
",",
"default_css",
")",
":",
"self",
".",
"title",
"=",
"title",
"self",
".",
"write",
"(",
"'''<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n ... | Writes the head part for the generated document,
with the given title and CSS | [
"Writes",
"the",
"head",
"part",
"for",
"the",
"generated",
"document",
"with",
"the",
"given",
"title",
"and",
"CSS"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L42-L68 | train | Writes the head part for the generated document with the given title and CSS. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.set_menu_separator | def set_menu_separator(self, img):
"""Sets the menu separator.
Must be called before adding entries to the menu
"""
if img:
self.menu_separator_tag = '<img src="{}" alt="/" />'.format(
self._rel(img))
else:
self.menu_separator_tag = None | python | def set_menu_separator(self, img):
"""Sets the menu separator.
Must be called before adding entries to the menu
"""
if img:
self.menu_separator_tag = '<img src="{}" alt="/" />'.format(
self._rel(img))
else:
self.menu_separator_tag = None | [
"def",
"set_menu_separator",
"(",
"self",
",",
"img",
")",
":",
"if",
"img",
":",
"self",
".",
"menu_separator_tag",
"=",
"'<img src=\"{}\" alt=\"/\" />'",
".",
"format",
"(",
"self",
".",
"_rel",
"(",
"img",
")",
")",
"else",
":",
"self",
".",
"menu_separ... | Sets the menu separator.
Must be called before adding entries to the menu | [
"Sets",
"the",
"menu",
"separator",
".",
"Must",
"be",
"called",
"before",
"adding",
"entries",
"to",
"the",
"menu"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L70-L78 | train | Sets the menu separator. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.add_menu | def add_menu(self, name, link=None):
"""Adds a menu entry, will create it if it doesn't exist yet"""
if self.menu_began:
if self.menu_separator_tag:
self.write(self.menu_separator_tag)
else:
# First time, create the menu tag
self.write('<ul cla... | python | def add_menu(self, name, link=None):
"""Adds a menu entry, will create it if it doesn't exist yet"""
if self.menu_began:
if self.menu_separator_tag:
self.write(self.menu_separator_tag)
else:
# First time, create the menu tag
self.write('<ul cla... | [
"def",
"add_menu",
"(",
"self",
",",
"name",
",",
"link",
"=",
"None",
")",
":",
"if",
"self",
".",
"menu_began",
":",
"if",
"self",
".",
"menu_separator_tag",
":",
"self",
".",
"write",
"(",
"self",
".",
"menu_separator_tag",
")",
"else",
":",
"# Firs... | Adds a menu entry, will create it if it doesn't exist yet | [
"Adds",
"a",
"menu",
"entry",
"will",
"create",
"it",
"if",
"it",
"doesn",
"t",
"exist",
"yet"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L80-L99 | train | Adds a menu entry. Will create it if it doesn t exist yet. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.write_title | def write_title(self, title, level=1, id=None):
"""Writes a title header in the document body,
with an optional depth level
"""
if id:
self.write('<h{lv} id="{id}">{title}</h{lv}>',
title=title, lv=level, id=id)
else:
self.write('... | python | def write_title(self, title, level=1, id=None):
"""Writes a title header in the document body,
with an optional depth level
"""
if id:
self.write('<h{lv} id="{id}">{title}</h{lv}>',
title=title, lv=level, id=id)
else:
self.write('... | [
"def",
"write_title",
"(",
"self",
",",
"title",
",",
"level",
"=",
"1",
",",
"id",
"=",
"None",
")",
":",
"if",
"id",
":",
"self",
".",
"write",
"(",
"'<h{lv} id=\"{id}\">{title}</h{lv}>'",
",",
"title",
"=",
"title",
",",
"lv",
"=",
"level",
",",
"... | Writes a title header in the document body,
with an optional depth level | [
"Writes",
"a",
"title",
"header",
"in",
"the",
"document",
"body",
"with",
"an",
"optional",
"depth",
"level"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L107-L116 | train | Writes a title header in the document body | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.write_code | def write_code(self, tlobject):
"""Writes the code for the given 'tlobject' properly
formatted with hyperlinks
"""
self.write('<pre>---{}---\n',
'functions' if tlobject.is_function else 'types')
# Write the function or type and its ID
if tlobject.na... | python | def write_code(self, tlobject):
"""Writes the code for the given 'tlobject' properly
formatted with hyperlinks
"""
self.write('<pre>---{}---\n',
'functions' if tlobject.is_function else 'types')
# Write the function or type and its ID
if tlobject.na... | [
"def",
"write_code",
"(",
"self",
",",
"tlobject",
")",
":",
"self",
".",
"write",
"(",
"'<pre>---{}---\\n'",
",",
"'functions'",
"if",
"tlobject",
".",
"is_function",
"else",
"'types'",
")",
"# Write the function or type and its ID",
"if",
"tlobject",
".",
"names... | Writes the code for the given 'tlobject' properly
formatted with hyperlinks | [
"Writes",
"the",
"code",
"for",
"the",
"given",
"tlobject",
"properly",
"formatted",
"with",
"hyperlinks"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L118-L197 | train | Writes the code for the given tlobject properly with hyperlinks
. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.begin_table | def begin_table(self, column_count):
"""Begins a table with the given 'column_count', required to automatically
create the right amount of columns when adding items to the rows"""
self.table_columns = column_count
self.table_columns_left = 0
self.write('<table>') | python | def begin_table(self, column_count):
"""Begins a table with the given 'column_count', required to automatically
create the right amount of columns when adding items to the rows"""
self.table_columns = column_count
self.table_columns_left = 0
self.write('<table>') | [
"def",
"begin_table",
"(",
"self",
",",
"column_count",
")",
":",
"self",
".",
"table_columns",
"=",
"column_count",
"self",
".",
"table_columns_left",
"=",
"0",
"self",
".",
"write",
"(",
"'<table>'",
")"
] | Begins a table with the given 'column_count', required to automatically
create the right amount of columns when adding items to the rows | [
"Begins",
"a",
"table",
"with",
"the",
"given",
"column_count",
"required",
"to",
"automatically",
"create",
"the",
"right",
"amount",
"of",
"columns",
"when",
"adding",
"items",
"to",
"the",
"rows"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L199-L204 | train | Starts a table with the given column_count required to automatically generate the right amount of columns when adding items to the rows | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.add_row | def add_row(self, text, link=None, bold=False, align=None):
"""This will create a new row, or add text to the next column
of the previously created, incomplete row, closing it if complete"""
if not self.table_columns_left:
# Starting a new row
self.write('<tr>')
... | python | def add_row(self, text, link=None, bold=False, align=None):
"""This will create a new row, or add text to the next column
of the previously created, incomplete row, closing it if complete"""
if not self.table_columns_left:
# Starting a new row
self.write('<tr>')
... | [
"def",
"add_row",
"(",
"self",
",",
"text",
",",
"link",
"=",
"None",
",",
"bold",
"=",
"False",
",",
"align",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"table_columns_left",
":",
"# Starting a new row",
"self",
".",
"write",
"(",
"'<tr>'",
")",... | This will create a new row, or add text to the next column
of the previously created, incomplete row, closing it if complete | [
"This",
"will",
"create",
"a",
"new",
"row",
"or",
"add",
"text",
"to",
"the",
"next",
"column",
"of",
"the",
"previously",
"created",
"incomplete",
"row",
"closing",
"it",
"if",
"complete"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L206-L236 | train | This will create a new row or add text to the next column
of the previously created incomplete row. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.write_copy_button | def write_copy_button(self, text, text_to_copy):
"""Writes a button with 'text' which can be used
to copy 'text_to_copy' to clipboard when it's clicked."""
self.write_copy_script = True
self.write('<button onclick="cp(\'{}\');">{}</button>'
.format(text_to_copy, tex... | python | def write_copy_button(self, text, text_to_copy):
"""Writes a button with 'text' which can be used
to copy 'text_to_copy' to clipboard when it's clicked."""
self.write_copy_script = True
self.write('<button onclick="cp(\'{}\');">{}</button>'
.format(text_to_copy, tex... | [
"def",
"write_copy_button",
"(",
"self",
",",
"text",
",",
"text_to_copy",
")",
":",
"self",
".",
"write_copy_script",
"=",
"True",
"self",
".",
"write",
"(",
"'<button onclick=\"cp(\\'{}\\');\">{}</button>'",
".",
"format",
"(",
"text_to_copy",
",",
"text",
")",
... | Writes a button with 'text' which can be used
to copy 'text_to_copy' to clipboard when it's clicked. | [
"Writes",
"a",
"button",
"with",
"text",
"which",
"can",
"be",
"used",
"to",
"copy",
"text_to_copy",
"to",
"clipboard",
"when",
"it",
"s",
"clicked",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L249-L254 | train | Writes a button with text which can be used
to copy text_to_copy to clipboard when it s clicked. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.end_body | def end_body(self):
"""Ends the whole document. This should be called the last"""
if self.write_copy_script:
self.write(
'<textarea id="c" class="invisible"></textarea>'
'<script>'
'function cp(t){'
'var c=document.getElementByI... | python | def end_body(self):
"""Ends the whole document. This should be called the last"""
if self.write_copy_script:
self.write(
'<textarea id="c" class="invisible"></textarea>'
'<script>'
'function cp(t){'
'var c=document.getElementByI... | [
"def",
"end_body",
"(",
"self",
")",
":",
"if",
"self",
".",
"write_copy_script",
":",
"self",
".",
"write",
"(",
"'<textarea id=\"c\" class=\"invisible\"></textarea>'",
"'<script>'",
"'function cp(t){'",
"'var c=document.getElementById(\"c\");'",
"'c.value=t;'",
"'c.select()... | Ends the whole document. This should be called the last | [
"Ends",
"the",
"whole",
"document",
".",
"This",
"should",
"be",
"called",
"the",
"last"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L263-L278 | train | Ends the whole document. This should be called the last. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/docswriter.py | DocsWriter.write | def write(self, s, *args, **kwargs):
"""Wrapper around handle.write"""
if args or kwargs:
self.handle.write(s.format(*args, **kwargs))
else:
self.handle.write(s) | python | def write(self, s, *args, **kwargs):
"""Wrapper around handle.write"""
if args or kwargs:
self.handle.write(s.format(*args, **kwargs))
else:
self.handle.write(s) | [
"def",
"write",
"(",
"self",
",",
"s",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
"or",
"kwargs",
":",
"self",
".",
"handle",
".",
"write",
"(",
"s",
".",
"format",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
... | Wrapper around handle.write | [
"Wrapper",
"around",
"handle",
".",
"write"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L281-L286 | train | Wrapper around handle. write. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/chats.py | ChatMethods.iter_participants | def iter_participants(
self, entity, limit=None, *, search='',
filter=None, aggressive=False
):
"""
Iterator over the participants belonging to the specified chat.
Args:
entity (`entity`):
The entity from which to retrieve the participants... | python | def iter_participants(
self, entity, limit=None, *, search='',
filter=None, aggressive=False
):
"""
Iterator over the participants belonging to the specified chat.
Args:
entity (`entity`):
The entity from which to retrieve the participants... | [
"def",
"iter_participants",
"(",
"self",
",",
"entity",
",",
"limit",
"=",
"None",
",",
"*",
",",
"search",
"=",
"''",
",",
"filter",
"=",
"None",
",",
"aggressive",
"=",
"False",
")",
":",
"return",
"_ParticipantsIter",
"(",
"self",
",",
"limit",
",",... | Iterator over the participants belonging to the specified chat.
Args:
entity (`entity`):
The entity from which to retrieve the participants list.
limit (`int`):
Limits amount of participants fetched.
search (`str`, optional):
... | [
"Iterator",
"over",
"the",
"participants",
"belonging",
"to",
"the",
"specified",
"chat",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/chats.py#L277-L331 | train | Returns an iterator over the participants in the specified chat. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/chats.py | ChatMethods.iter_admin_log | def iter_admin_log(
self, entity, limit=None, *, max_id=0, min_id=0, search=None,
admins=None, join=None, leave=None, invite=None, restrict=None,
unrestrict=None, ban=None, unban=None, promote=None, demote=None,
info=None, settings=None, pinned=None, edit=None, delete=Non... | python | def iter_admin_log(
self, entity, limit=None, *, max_id=0, min_id=0, search=None,
admins=None, join=None, leave=None, invite=None, restrict=None,
unrestrict=None, ban=None, unban=None, promote=None, demote=None,
info=None, settings=None, pinned=None, edit=None, delete=Non... | [
"def",
"iter_admin_log",
"(",
"self",
",",
"entity",
",",
"limit",
"=",
"None",
",",
"*",
",",
"max_id",
"=",
"0",
",",
"min_id",
"=",
"0",
",",
"search",
"=",
"None",
",",
"admins",
"=",
"None",
",",
"join",
"=",
"None",
",",
"leave",
"=",
"None... | Iterator over the admin log for the specified channel.
Note that you must be an administrator of it to use this method.
If none of the filters are present (i.e. they all are ``None``),
*all* event types will be returned. If at least one of them is
``True``, only those that are true wil... | [
"Iterator",
"over",
"the",
"admin",
"log",
"for",
"the",
"specified",
"channel",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/chats.py#L340-L454 | train | This method returns an iterator over the admin log for the specified channel. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/client/chats.py | ChatMethods.action | def action(self, entity, action, *, delay=4, auto_cancel=True):
"""
Returns a context-manager object to represent a "chat action".
Chat actions indicate things like "user is typing", "user is
uploading a photo", etc. Normal usage is as follows:
.. code-block:: python
... | python | def action(self, entity, action, *, delay=4, auto_cancel=True):
"""
Returns a context-manager object to represent a "chat action".
Chat actions indicate things like "user is typing", "user is
uploading a photo", etc. Normal usage is as follows:
.. code-block:: python
... | [
"def",
"action",
"(",
"self",
",",
"entity",
",",
"action",
",",
"*",
",",
"delay",
"=",
"4",
",",
"auto_cancel",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"action",
",",
"str",
")",
":",
"try",
":",
"action",
"=",
"_ChatAction",
".",
"_str_m... | Returns a context-manager object to represent a "chat action".
Chat actions indicate things like "user is typing", "user is
uploading a photo", etc. Normal usage is as follows:
.. code-block:: python
async with client.action(chat, 'typing'):
await asyncio.sleep(2) ... | [
"Returns",
"a",
"context",
"-",
"manager",
"object",
"to",
"represent",
"a",
"chat",
"action",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/chats.py#L462-L544 | train | This function returns a context - manager object that represents a chat action. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/crypto/cdndecrypter.py | CdnDecrypter.prepare_decrypter | async def prepare_decrypter(client, cdn_client, cdn_redirect):
"""
Prepares a new CDN decrypter.
:param client: a TelegramClient connected to the main servers.
:param cdn_client: a new client connected to the CDN.
:param cdn_redirect: the redirect file object that caused this ca... | python | async def prepare_decrypter(client, cdn_client, cdn_redirect):
"""
Prepares a new CDN decrypter.
:param client: a TelegramClient connected to the main servers.
:param cdn_client: a new client connected to the CDN.
:param cdn_redirect: the redirect file object that caused this ca... | [
"async",
"def",
"prepare_decrypter",
"(",
"client",
",",
"cdn_client",
",",
"cdn_redirect",
")",
":",
"cdn_aes",
"=",
"AESModeCTR",
"(",
"key",
"=",
"cdn_redirect",
".",
"encryption_key",
",",
"# 12 first bytes of the IV..4 bytes of the offset (0, big endian)",
"iv",
"=... | Prepares a new CDN decrypter.
:param client: a TelegramClient connected to the main servers.
:param cdn_client: a new client connected to the CDN.
:param cdn_redirect: the redirect file object that caused this call.
:return: (CdnDecrypter, first chunk file data) | [
"Prepares",
"a",
"new",
"CDN",
"decrypter",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/crypto/cdndecrypter.py#L33-L74 | train | Prepare a new CDN decrypter. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/crypto/cdndecrypter.py | CdnDecrypter.get_file | def get_file(self):
"""
Calls GetCdnFileRequest and decrypts its bytes.
Also ensures that the file hasn't been tampered.
:return: the CdnFile result.
"""
if self.cdn_file_hashes:
cdn_hash = self.cdn_file_hashes.pop(0)
cdn_file = self.client(GetCdn... | python | def get_file(self):
"""
Calls GetCdnFileRequest and decrypts its bytes.
Also ensures that the file hasn't been tampered.
:return: the CdnFile result.
"""
if self.cdn_file_hashes:
cdn_hash = self.cdn_file_hashes.pop(0)
cdn_file = self.client(GetCdn... | [
"def",
"get_file",
"(",
"self",
")",
":",
"if",
"self",
".",
"cdn_file_hashes",
":",
"cdn_hash",
"=",
"self",
".",
"cdn_file_hashes",
".",
"pop",
"(",
"0",
")",
"cdn_file",
"=",
"self",
".",
"client",
"(",
"GetCdnFileRequest",
"(",
"self",
".",
"file_tok... | Calls GetCdnFileRequest and decrypts its bytes.
Also ensures that the file hasn't been tampered.
:return: the CdnFile result. | [
"Calls",
"GetCdnFileRequest",
"and",
"decrypts",
"its",
"bytes",
".",
"Also",
"ensures",
"that",
"the",
"file",
"hasn",
"t",
"been",
"tampered",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/crypto/cdndecrypter.py#L76-L93 | train | Calls GetCdnFileRequest and decrypts its bytes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/extensions/html.py | parse | def parse(html):
"""
Parses the given HTML message and returns its stripped representation
plus a list of the MessageEntity's that were found.
:param message: the message with HTML to be parsed.
:return: a tuple consisting of (clean message, [message entities]).
"""
if not html:
ret... | python | def parse(html):
"""
Parses the given HTML message and returns its stripped representation
plus a list of the MessageEntity's that were found.
:param message: the message with HTML to be parsed.
:return: a tuple consisting of (clean message, [message entities]).
"""
if not html:
ret... | [
"def",
"parse",
"(",
"html",
")",
":",
"if",
"not",
"html",
":",
"return",
"html",
",",
"[",
"]",
"parser",
"=",
"HTMLToTelegramParser",
"(",
")",
"parser",
".",
"feed",
"(",
"_add_surrogate",
"(",
"html",
")",
")",
"text",
"=",
"helpers",
".",
"stri... | Parses the given HTML message and returns its stripped representation
plus a list of the MessageEntity's that were found.
:param message: the message with HTML to be parsed.
:return: a tuple consisting of (clean message, [message entities]). | [
"Parses",
"the",
"given",
"HTML",
"message",
"and",
"returns",
"its",
"stripped",
"representation",
"plus",
"a",
"list",
"of",
"the",
"MessageEntity",
"s",
"that",
"were",
"found",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/extensions/html.py#L117-L131 | train | Parses the given HTML message and returns its stripped representation and a list of the MessageEntity s that were found. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/extensions/html.py | unparse | def unparse(text, entities):
"""
Performs the reverse operation to .parse(), effectively returning HTML
given a normal text and its MessageEntity's.
:param text: the text to be reconverted into HTML.
:param entities: the MessageEntity's applied to the text.
:return: a HTML representation of the... | python | def unparse(text, entities):
"""
Performs the reverse operation to .parse(), effectively returning HTML
given a normal text and its MessageEntity's.
:param text: the text to be reconverted into HTML.
:param entities: the MessageEntity's applied to the text.
:return: a HTML representation of the... | [
"def",
"unparse",
"(",
"text",
",",
"entities",
")",
":",
"if",
"not",
"text",
"or",
"not",
"entities",
":",
"return",
"text",
"text",
"=",
"_add_surrogate",
"(",
"text",
")",
"html",
"=",
"[",
"]",
"last_offset",
"=",
"0",
"for",
"entity",
"in",
"en... | Performs the reverse operation to .parse(), effectively returning HTML
given a normal text and its MessageEntity's.
:param text: the text to be reconverted into HTML.
:param entities: the MessageEntity's applied to the text.
:return: a HTML representation of the combination of both inputs. | [
"Performs",
"the",
"reverse",
"operation",
"to",
".",
"parse",
"()",
"effectively",
"returning",
"HTML",
"given",
"a",
"normal",
"text",
"and",
"its",
"MessageEntity",
"s",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/extensions/html.py#L134-L190 | train | This function performs the reverse operation to. parse effectively returning a HTML representation of the text and its MessageEntity s. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/custom/messagebutton.py | MessageButton.data | def data(self):
"""The ``bytes`` data for :tl:`KeyboardButtonCallback` objects."""
if isinstance(self.button, types.KeyboardButtonCallback):
return self.button.data | python | def data(self):
"""The ``bytes`` data for :tl:`KeyboardButtonCallback` objects."""
if isinstance(self.button, types.KeyboardButtonCallback):
return self.button.data | [
"def",
"data",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"button",
",",
"types",
".",
"KeyboardButtonCallback",
")",
":",
"return",
"self",
".",
"button",
".",
"data"
] | The ``bytes`` data for :tl:`KeyboardButtonCallback` objects. | [
"The",
"bytes",
"data",
"for",
":",
"tl",
":",
"KeyboardButtonCallback",
"objects",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/messagebutton.py#L45-L48 | train | The bytes data for this button. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/custom/messagebutton.py | MessageButton.inline_query | def inline_query(self):
"""The query ``str`` for :tl:`KeyboardButtonSwitchInline` objects."""
if isinstance(self.button, types.KeyboardButtonSwitchInline):
return self.button.query | python | def inline_query(self):
"""The query ``str`` for :tl:`KeyboardButtonSwitchInline` objects."""
if isinstance(self.button, types.KeyboardButtonSwitchInline):
return self.button.query | [
"def",
"inline_query",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"button",
",",
"types",
".",
"KeyboardButtonSwitchInline",
")",
":",
"return",
"self",
".",
"button",
".",
"query"
] | The query ``str`` for :tl:`KeyboardButtonSwitchInline` objects. | [
"The",
"query",
"str",
"for",
":",
"tl",
":",
"KeyboardButtonSwitchInline",
"objects",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/messagebutton.py#L51-L54 | train | The query str for inline buttons. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/custom/messagebutton.py | MessageButton.url | def url(self):
"""The url ``str`` for :tl:`KeyboardButtonUrl` objects."""
if isinstance(self.button, types.KeyboardButtonUrl):
return self.button.url | python | def url(self):
"""The url ``str`` for :tl:`KeyboardButtonUrl` objects."""
if isinstance(self.button, types.KeyboardButtonUrl):
return self.button.url | [
"def",
"url",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"button",
",",
"types",
".",
"KeyboardButtonUrl",
")",
":",
"return",
"self",
".",
"button",
".",
"url"
] | The url ``str`` for :tl:`KeyboardButtonUrl` objects. | [
"The",
"url",
"str",
"for",
":",
"tl",
":",
"KeyboardButtonUrl",
"objects",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/messagebutton.py#L57-L60 | train | The url str for this button. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/custom/messagebutton.py | MessageButton.click | async def click(self):
"""
Emulates the behaviour of clicking this button.
If it's a normal :tl:`KeyboardButton` with text, a message will be
sent, and the sent `telethon.tl.custom.message.Message` returned.
If it's an inline :tl:`KeyboardButtonCallback` with text and data,
... | python | async def click(self):
"""
Emulates the behaviour of clicking this button.
If it's a normal :tl:`KeyboardButton` with text, a message will be
sent, and the sent `telethon.tl.custom.message.Message` returned.
If it's an inline :tl:`KeyboardButtonCallback` with text and data,
... | [
"async",
"def",
"click",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"button",
",",
"types",
".",
"KeyboardButton",
")",
":",
"return",
"await",
"self",
".",
"_client",
".",
"send_message",
"(",
"self",
".",
"_chat",
",",
"self",
".",
... | Emulates the behaviour of clicking this button.
If it's a normal :tl:`KeyboardButton` with text, a message will be
sent, and the sent `telethon.tl.custom.message.Message` returned.
If it's an inline :tl:`KeyboardButtonCallback` with text and data,
it will be "clicked" and the :tl:`BotC... | [
"Emulates",
"the",
"behaviour",
"of",
"clicking",
"this",
"button",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/messagebutton.py#L62-L103 | train | Clicks the specified keyboard button. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/events/common.py | _into_id_set | async def _into_id_set(client, chats):
"""Helper util to turn the input chat or chats into a set of IDs."""
if chats is None:
return None
if not utils.is_list_like(chats):
chats = (chats,)
result = set()
for chat in chats:
if isinstance(chat, int):
if chat < 0:
... | python | async def _into_id_set(client, chats):
"""Helper util to turn the input chat or chats into a set of IDs."""
if chats is None:
return None
if not utils.is_list_like(chats):
chats = (chats,)
result = set()
for chat in chats:
if isinstance(chat, int):
if chat < 0:
... | [
"async",
"def",
"_into_id_set",
"(",
"client",
",",
"chats",
")",
":",
"if",
"chats",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"utils",
".",
"is_list_like",
"(",
"chats",
")",
":",
"chats",
"=",
"(",
"chats",
",",
")",
"result",
"=",
"set",
... | Helper util to turn the input chat or chats into a set of IDs. | [
"Helper",
"util",
"to",
"turn",
"the",
"input",
"chat",
"or",
"chats",
"into",
"a",
"set",
"of",
"IDs",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L11-L39 | train | Helper util to turn the input chat or chats into a set of IDs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/events/common.py | name_inner_event | def name_inner_event(cls):
"""Decorator to rename cls.Event 'Event' as 'cls.Event'"""
if hasattr(cls, 'Event'):
cls.Event._event_name = '{}.Event'.format(cls.__name__)
else:
warnings.warn('Class {} does not have a inner Event'.format(cls))
return cls | python | def name_inner_event(cls):
"""Decorator to rename cls.Event 'Event' as 'cls.Event'"""
if hasattr(cls, 'Event'):
cls.Event._event_name = '{}.Event'.format(cls.__name__)
else:
warnings.warn('Class {} does not have a inner Event'.format(cls))
return cls | [
"def",
"name_inner_event",
"(",
"cls",
")",
":",
"if",
"hasattr",
"(",
"cls",
",",
"'Event'",
")",
":",
"cls",
".",
"Event",
".",
"_event_name",
"=",
"'{}.Event'",
".",
"format",
"(",
"cls",
".",
"__name__",
")",
"else",
":",
"warnings",
".",
"warn",
... | Decorator to rename cls.Event 'Event' as 'cls.Event | [
"Decorator",
"to",
"rename",
"cls",
".",
"Event",
"Event",
"as",
"cls",
".",
"Event"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L242-L248 | train | Decorator to rename cls. Event as cls. Event | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/events/common.py | EventBuilder.resolve | async def resolve(self, client):
"""Helper method to allow event builders to be resolved before usage"""
if self.resolved:
return
if not self._resolve_lock:
self._resolve_lock = asyncio.Lock(loop=client.loop)
async with self._resolve_lock:
if not sel... | python | async def resolve(self, client):
"""Helper method to allow event builders to be resolved before usage"""
if self.resolved:
return
if not self._resolve_lock:
self._resolve_lock = asyncio.Lock(loop=client.loop)
async with self._resolve_lock:
if not sel... | [
"async",
"def",
"resolve",
"(",
"self",
",",
"client",
")",
":",
"if",
"self",
".",
"resolved",
":",
"return",
"if",
"not",
"self",
".",
"_resolve_lock",
":",
"self",
".",
"_resolve_lock",
"=",
"asyncio",
".",
"Lock",
"(",
"loop",
"=",
"client",
".",
... | Helper method to allow event builders to be resolved before usage | [
"Helper",
"method",
"to",
"allow",
"event",
"builders",
"to",
"be",
"resolved",
"before",
"usage"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L83-L94 | train | Resolve the event builders. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/events/common.py | EventBuilder.filter | def filter(self, event):
"""
If the ID of ``event._chat_peer`` isn't in the chats set (or it is
but the set is a blacklist) returns ``None``, otherwise the event.
The events must have been resolved before this can be called.
"""
if not self.resolved:
return N... | python | def filter(self, event):
"""
If the ID of ``event._chat_peer`` isn't in the chats set (or it is
but the set is a blacklist) returns ``None``, otherwise the event.
The events must have been resolved before this can be called.
"""
if not self.resolved:
return N... | [
"def",
"filter",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"self",
".",
"resolved",
":",
"return",
"None",
"if",
"self",
".",
"chats",
"is",
"not",
"None",
":",
"# Note: the `event.chat_id` property checks if it's `None` for us",
"inside",
"=",
"event",
... | If the ID of ``event._chat_peer`` isn't in the chats set (or it is
but the set is a blacklist) returns ``None``, otherwise the event.
The events must have been resolved before this can be called. | [
"If",
"the",
"ID",
"of",
"event",
".",
"_chat_peer",
"isn",
"t",
"in",
"the",
"chats",
"set",
"(",
"or",
"it",
"is",
"but",
"the",
"set",
"is",
"a",
"blacklist",
")",
"returns",
"None",
"otherwise",
"the",
"event",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L101-L120 | train | Filter out events that are not in the set of chats. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/events/common.py | EventCommon._get_entity_pair | def _get_entity_pair(self, entity_id):
"""
Returns ``(entity, input_entity)`` for the given entity ID.
"""
entity = self._entities.get(entity_id)
try:
input_entity = utils.get_input_peer(entity)
except TypeError:
try:
input_entity =... | python | def _get_entity_pair(self, entity_id):
"""
Returns ``(entity, input_entity)`` for the given entity ID.
"""
entity = self._entities.get(entity_id)
try:
input_entity = utils.get_input_peer(entity)
except TypeError:
try:
input_entity =... | [
"def",
"_get_entity_pair",
"(",
"self",
",",
"entity_id",
")",
":",
"entity",
"=",
"self",
".",
"_entities",
".",
"get",
"(",
"entity_id",
")",
"try",
":",
"input_entity",
"=",
"utils",
".",
"get_input_peer",
"(",
"entity",
")",
"except",
"TypeError",
":",... | Returns ``(entity, input_entity)`` for the given entity ID. | [
"Returns",
"(",
"entity",
"input_entity",
")",
"for",
"the",
"given",
"entity",
"ID",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L152-L165 | train | Returns the entity and input entity pair for the given entity ID. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/events/common.py | EventCommon._load_entities | def _load_entities(self):
"""
Must load all the entities it needs from cache, and
return ``False`` if it could not find all of them.
"""
if not self._chat_peer:
return True # Nothing to load (e.g. MessageDeleted)
self._chat, self._input_chat = self._get_enti... | python | def _load_entities(self):
"""
Must load all the entities it needs from cache, and
return ``False`` if it could not find all of them.
"""
if not self._chat_peer:
return True # Nothing to load (e.g. MessageDeleted)
self._chat, self._input_chat = self._get_enti... | [
"def",
"_load_entities",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_chat_peer",
":",
"return",
"True",
"# Nothing to load (e.g. MessageDeleted)",
"self",
".",
"_chat",
",",
"self",
".",
"_input_chat",
"=",
"self",
".",
"_get_entity_pair",
"(",
"self",
... | Must load all the entities it needs from cache, and
return ``False`` if it could not find all of them. | [
"Must",
"load",
"all",
"the",
"entities",
"it",
"needs",
"from",
"cache",
"and",
"return",
"False",
"if",
"it",
"could",
"not",
"find",
"all",
"of",
"them",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L167-L176 | train | Load all the entities from cache and return True if all of them are loaded False otherwise. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/events/common.py | EventCommon._get_difference | async def _get_difference(self, channel_id, pts_date):
"""
Get the difference for this `channel_id` if any, then load entities.
Calls :tl:`updates.getDifference`, which fills the entities cache
(always done by `__call__`) and lets us know about the full entities.
"""
# F... | python | async def _get_difference(self, channel_id, pts_date):
"""
Get the difference for this `channel_id` if any, then load entities.
Calls :tl:`updates.getDifference`, which fills the entities cache
(always done by `__call__`) and lets us know about the full entities.
"""
# F... | [
"async",
"def",
"_get_difference",
"(",
"self",
",",
"channel_id",
",",
"pts_date",
")",
":",
"# Fetch since the last known pts/date before this update arrived,",
"# in order to fetch this update at full, including its entities.",
"self",
".",
"client",
".",
"_log",
"[",
"__nam... | Get the difference for this `channel_id` if any, then load entities.
Calls :tl:`updates.getDifference`, which fills the entities cache
(always done by `__call__`) and lets us know about the full entities. | [
"Get",
"the",
"difference",
"for",
"this",
"channel_id",
"if",
"any",
"then",
"load",
"entities",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L178-L221 | train | Get the difference for this channel_id and pts_date. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/custom/chatgetter.py | ChatGetter.get_chat | async def get_chat(self):
"""
Returns `chat`, but will make an API call to find the
chat unless it's already cached.
"""
# See `get_sender` for information about 'min'.
if (self._chat is None or getattr(self._chat, 'min', None))\
and await self.get_input_c... | python | async def get_chat(self):
"""
Returns `chat`, but will make an API call to find the
chat unless it's already cached.
"""
# See `get_sender` for information about 'min'.
if (self._chat is None or getattr(self._chat, 'min', None))\
and await self.get_input_c... | [
"async",
"def",
"get_chat",
"(",
"self",
")",
":",
"# See `get_sender` for information about 'min'.",
"if",
"(",
"self",
".",
"_chat",
"is",
"None",
"or",
"getattr",
"(",
"self",
".",
"_chat",
",",
"'min'",
",",
"None",
")",
")",
"and",
"await",
"self",
".... | Returns `chat`, but will make an API call to find the
chat unless it's already cached. | [
"Returns",
"chat",
"but",
"will",
"make",
"an",
"API",
"call",
"to",
"find",
"the",
"chat",
"unless",
"it",
"s",
"already",
"cached",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/chatgetter.py#L27-L40 | train | Returns the chat if it s not already cached. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/custom/chatgetter.py | ChatGetter.input_chat | def input_chat(self):
"""
This :tl:`InputPeer` is the input version of the chat where the
message was sent. Similarly to `input_sender`, this doesn't have
things like username or similar, but still useful in some cases.
Note that this might not be available if the library doesn'... | python | def input_chat(self):
"""
This :tl:`InputPeer` is the input version of the chat where the
message was sent. Similarly to `input_sender`, this doesn't have
things like username or similar, but still useful in some cases.
Note that this might not be available if the library doesn'... | [
"def",
"input_chat",
"(",
"self",
")",
":",
"if",
"self",
".",
"_input_chat",
"is",
"None",
"and",
"self",
".",
"_chat_peer",
":",
"try",
":",
"self",
".",
"_input_chat",
"=",
"self",
".",
"_client",
".",
"_entity_cache",
"[",
"self",
".",
"_chat_peer",
... | This :tl:`InputPeer` is the input version of the chat where the
message was sent. Similarly to `input_sender`, this doesn't have
things like username or similar, but still useful in some cases.
Note that this might not be available if the library doesn't
have enough information availabl... | [
"This",
":",
"tl",
":",
"InputPeer",
"is",
"the",
"input",
"version",
"of",
"the",
"chat",
"where",
"the",
"message",
"was",
"sent",
".",
"Similarly",
"to",
"input_sender",
"this",
"doesn",
"t",
"have",
"things",
"like",
"username",
"or",
"similar",
"but",... | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/chatgetter.py#L43-L58 | train | This is the input version of the chat where the message was sent. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/custom/chatgetter.py | ChatGetter.get_input_chat | async def get_input_chat(self):
"""
Returns `input_chat`, but will make an API call to find the
input chat unless it's already cached.
"""
if self.input_chat is None and self.chat_id:
try:
# The chat may be recent, look in dialogs
targe... | python | async def get_input_chat(self):
"""
Returns `input_chat`, but will make an API call to find the
input chat unless it's already cached.
"""
if self.input_chat is None and self.chat_id:
try:
# The chat may be recent, look in dialogs
targe... | [
"async",
"def",
"get_input_chat",
"(",
"self",
")",
":",
"if",
"self",
".",
"input_chat",
"is",
"None",
"and",
"self",
".",
"chat_id",
":",
"try",
":",
"# The chat may be recent, look in dialogs",
"target",
"=",
"self",
".",
"chat_id",
"async",
"for",
"d",
"... | Returns `input_chat`, but will make an API call to find the
input chat unless it's already cached. | [
"Returns",
"input_chat",
"but",
"will",
"make",
"an",
"API",
"call",
"to",
"find",
"the",
"input",
"chat",
"unless",
"it",
"s",
"already",
"cached",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/chatgetter.py#L60-L77 | train | Returns the input chat if it s not already cached. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/tl/custom/chatgetter.py | ChatGetter.is_group | def is_group(self):
"""True if the message was sent on a group or megagroup."""
if self._broadcast is None and self.chat:
self._broadcast = getattr(self.chat, 'broadcast', None)
return (
isinstance(self._chat_peer, (types.PeerChat, types.PeerChannel))
and not... | python | def is_group(self):
"""True if the message was sent on a group or megagroup."""
if self._broadcast is None and self.chat:
self._broadcast = getattr(self.chat, 'broadcast', None)
return (
isinstance(self._chat_peer, (types.PeerChat, types.PeerChannel))
and not... | [
"def",
"is_group",
"(",
"self",
")",
":",
"if",
"self",
".",
"_broadcast",
"is",
"None",
"and",
"self",
".",
"chat",
":",
"self",
".",
"_broadcast",
"=",
"getattr",
"(",
"self",
".",
"chat",
",",
"'broadcast'",
",",
"None",
")",
"return",
"(",
"isins... | True if the message was sent on a group or megagroup. | [
"True",
"if",
"the",
"message",
"was",
"sent",
"on",
"a",
"group",
"or",
"megagroup",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/chatgetter.py#L97-L105 | train | True if the message was sent on a group or megagroup. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/helpers.py | generate_random_long | def generate_random_long(signed=True):
"""Generates a random long integer (8 bytes), which is optionally signed"""
return int.from_bytes(os.urandom(8), signed=signed, byteorder='little') | python | def generate_random_long(signed=True):
"""Generates a random long integer (8 bytes), which is optionally signed"""
return int.from_bytes(os.urandom(8), signed=signed, byteorder='little') | [
"def",
"generate_random_long",
"(",
"signed",
"=",
"True",
")",
":",
"return",
"int",
".",
"from_bytes",
"(",
"os",
".",
"urandom",
"(",
"8",
")",
",",
"signed",
"=",
"signed",
",",
"byteorder",
"=",
"'little'",
")"
] | Generates a random long integer (8 bytes), which is optionally signed | [
"Generates",
"a",
"random",
"long",
"integer",
"(",
"8",
"bytes",
")",
"which",
"is",
"optionally",
"signed"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/helpers.py#L11-L13 | train | Generates a random long integer which is optionally signed | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/helpers.py | ensure_parent_dir_exists | def ensure_parent_dir_exists(file_path):
"""Ensures that the parent directory exists"""
parent = os.path.dirname(file_path)
if parent:
os.makedirs(parent, exist_ok=True) | python | def ensure_parent_dir_exists(file_path):
"""Ensures that the parent directory exists"""
parent = os.path.dirname(file_path)
if parent:
os.makedirs(parent, exist_ok=True) | [
"def",
"ensure_parent_dir_exists",
"(",
"file_path",
")",
":",
"parent",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"file_path",
")",
"if",
"parent",
":",
"os",
".",
"makedirs",
"(",
"parent",
",",
"exist_ok",
"=",
"True",
")"
] | Ensures that the parent directory exists | [
"Ensures",
"that",
"the",
"parent",
"directory",
"exists"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/helpers.py#L16-L20 | train | Ensures that the parent directory exists | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/helpers.py | strip_text | def strip_text(text, entities):
"""
Strips whitespace from the given text modifying the provided entities.
This assumes that there are no overlapping entities, that their length
is greater or equal to one, and that their length is not out of bounds.
"""
if not entities:
return text.stri... | python | def strip_text(text, entities):
"""
Strips whitespace from the given text modifying the provided entities.
This assumes that there are no overlapping entities, that their length
is greater or equal to one, and that their length is not out of bounds.
"""
if not entities:
return text.stri... | [
"def",
"strip_text",
"(",
"text",
",",
"entities",
")",
":",
"if",
"not",
"entities",
":",
"return",
"text",
".",
"strip",
"(",
")",
"while",
"text",
"and",
"text",
"[",
"-",
"1",
"]",
".",
"isspace",
"(",
")",
":",
"e",
"=",
"entities",
"[",
"-"... | Strips whitespace from the given text modifying the provided entities.
This assumes that there are no overlapping entities, that their length
is greater or equal to one, and that their length is not out of bounds. | [
"Strips",
"whitespace",
"from",
"the",
"given",
"text",
"modifying",
"the",
"provided",
"entities",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/helpers.py#L36-L73 | train | Strips whitespace from the given text modifying the provided entities. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/helpers.py | _cancel | async def _cancel(log, **tasks):
"""
Helper to cancel one or more tasks gracefully, logging exceptions.
"""
for name, task in tasks.items():
if not task:
continue
task.cancel()
try:
await task
except asyncio.CancelledError:
pass
... | python | async def _cancel(log, **tasks):
"""
Helper to cancel one or more tasks gracefully, logging exceptions.
"""
for name, task in tasks.items():
if not task:
continue
task.cancel()
try:
await task
except asyncio.CancelledError:
pass
... | [
"async",
"def",
"_cancel",
"(",
"log",
",",
"*",
"*",
"tasks",
")",
":",
"for",
"name",
",",
"task",
"in",
"tasks",
".",
"items",
"(",
")",
":",
"if",
"not",
"task",
":",
"continue",
"task",
".",
"cancel",
"(",
")",
"try",
":",
"await",
"task",
... | Helper to cancel one or more tasks gracefully, logging exceptions. | [
"Helper",
"to",
"cancel",
"one",
"or",
"more",
"tasks",
"gracefully",
"logging",
"exceptions",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/helpers.py#L89-L103 | train | Helper to cancel one or more tasks gracefully logging exceptions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/helpers.py | _sync_enter | def _sync_enter(self):
"""
Helps to cut boilerplate on async context
managers that offer synchronous variants.
"""
if hasattr(self, 'loop'):
loop = self.loop
else:
loop = self._client.loop
if loop.is_running():
raise RuntimeError(
'You must use "async wit... | python | def _sync_enter(self):
"""
Helps to cut boilerplate on async context
managers that offer synchronous variants.
"""
if hasattr(self, 'loop'):
loop = self.loop
else:
loop = self._client.loop
if loop.is_running():
raise RuntimeError(
'You must use "async wit... | [
"def",
"_sync_enter",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'loop'",
")",
":",
"loop",
"=",
"self",
".",
"loop",
"else",
":",
"loop",
"=",
"self",
".",
"_client",
".",
"loop",
"if",
"loop",
".",
"is_running",
"(",
")",
":",
"... | Helps to cut boilerplate on async context
managers that offer synchronous variants. | [
"Helps",
"to",
"cut",
"boilerplate",
"on",
"async",
"context",
"managers",
"that",
"offer",
"synchronous",
"variants",
"."
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/helpers.py#L106-L122 | train | A synchronous enter. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon/helpers.py | generate_key_data_from_nonce | def generate_key_data_from_nonce(server_nonce, new_nonce):
"""Generates the key data corresponding to the given nonce"""
server_nonce = server_nonce.to_bytes(16, 'little', signed=True)
new_nonce = new_nonce.to_bytes(32, 'little', signed=True)
hash1 = sha1(new_nonce + server_nonce).digest()
hash2 = s... | python | def generate_key_data_from_nonce(server_nonce, new_nonce):
"""Generates the key data corresponding to the given nonce"""
server_nonce = server_nonce.to_bytes(16, 'little', signed=True)
new_nonce = new_nonce.to_bytes(32, 'little', signed=True)
hash1 = sha1(new_nonce + server_nonce).digest()
hash2 = s... | [
"def",
"generate_key_data_from_nonce",
"(",
"server_nonce",
",",
"new_nonce",
")",
":",
"server_nonce",
"=",
"server_nonce",
".",
"to_bytes",
"(",
"16",
",",
"'little'",
",",
"signed",
"=",
"True",
")",
"new_nonce",
"=",
"new_nonce",
".",
"to_bytes",
"(",
"32"... | Generates the key data corresponding to the given nonce | [
"Generates",
"the",
"key",
"data",
"corresponding",
"to",
"the",
"given",
"nonce"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/helpers.py#L139-L149 | train | Generates the key data corresponding to the given nonce | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/sourcebuilder.py | SourceBuilder.write | def write(self, string, *args, **kwargs):
"""Writes a string into the source code,
applying indentation if required
"""
if self.on_new_line:
self.on_new_line = False # We're not on a new line anymore
# If the string was not empty, indent; Else probably a new l... | python | def write(self, string, *args, **kwargs):
"""Writes a string into the source code,
applying indentation if required
"""
if self.on_new_line:
self.on_new_line = False # We're not on a new line anymore
# If the string was not empty, indent; Else probably a new l... | [
"def",
"write",
"(",
"self",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"on_new_line",
":",
"self",
".",
"on_new_line",
"=",
"False",
"# We're not on a new line anymore",
"# If the string was not empty, indent; Else prob... | Writes a string into the source code,
applying indentation if required | [
"Writes",
"a",
"string",
"into",
"the",
"source",
"code",
"applying",
"indentation",
"if",
"required"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/sourcebuilder.py#L19-L32 | train | Writes a string into the source code with indentation applied if required
is True | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/sourcebuilder.py | SourceBuilder.writeln | def writeln(self, string='', *args, **kwargs):
"""Writes a string into the source code _and_ appends a new line,
applying indentation if required
"""
self.write(string + '\n', *args, **kwargs)
self.on_new_line = True
# If we're writing a block, increment indent for th... | python | def writeln(self, string='', *args, **kwargs):
"""Writes a string into the source code _and_ appends a new line,
applying indentation if required
"""
self.write(string + '\n', *args, **kwargs)
self.on_new_line = True
# If we're writing a block, increment indent for th... | [
"def",
"writeln",
"(",
"self",
",",
"string",
"=",
"''",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"write",
"(",
"string",
"+",
"'\\n'",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"on_new_line",
"=",
"T... | Writes a string into the source code _and_ appends a new line,
applying indentation if required | [
"Writes",
"a",
"string",
"into",
"the",
"source",
"code",
"_and_",
"appends",
"a",
"new",
"line",
"applying",
"indentation",
"if",
"required"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/sourcebuilder.py#L34-L46 | train | Writes a string into the source code _and_ appends a new line | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
LonamiWebs/Telethon | telethon_generator/sourcebuilder.py | SourceBuilder.end_block | def end_block(self):
"""Ends an indentation block, leaving an empty line afterwards"""
self.current_indent -= 1
# If we did not add a new line automatically yet, now it's the time!
if not self.auto_added_line:
self.writeln()
self.auto_added_line = True | python | def end_block(self):
"""Ends an indentation block, leaving an empty line afterwards"""
self.current_indent -= 1
# If we did not add a new line automatically yet, now it's the time!
if not self.auto_added_line:
self.writeln()
self.auto_added_line = True | [
"def",
"end_block",
"(",
"self",
")",
":",
"self",
".",
"current_indent",
"-=",
"1",
"# If we did not add a new line automatically yet, now it's the time!",
"if",
"not",
"self",
".",
"auto_added_line",
":",
"self",
".",
"writeln",
"(",
")",
"self",
".",
"auto_added_... | Ends an indentation block, leaving an empty line afterwards | [
"Ends",
"an",
"indentation",
"block",
"leaving",
"an",
"empty",
"line",
"afterwards"
] | 1ead9757d366b58c1e0567cddb0196e20f1a445f | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/sourcebuilder.py#L48-L55 | train | Ends an indentation block leaving an empty line afterwards | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.