Comments (2)
comment
will be used for custom file attributes & types, so every developer may add own.
I suggest this standard:
- If
comment
is custom attributes, it must start from the one0xFF
byte. Otherwise this field will be determined as plain comment. - Every custom attribute must have the Key and the Value, like
dict()
. Value can beb''
.
As delimeters we may use length of Key (not to be confused with keys.Key
) and the length of Value.
I.e we want to add to the RemoteBoxFile
custom attribute key
with value value
. Then:
comment = b'\xff\x03key\x05value'
- We take
\x03
, convert it to int (3
) and take three next bytes, receive Key; - Take next byte from Key, convert it to int (
5
) and take next five bytes, receive Value; - Repeat until bytestring will be empty.
So, for example, we may use this to store file hash or signatures, or whatever.
We can also use this to determine file types, if needed. Let's use type
as Key.
Types can be combined, but there is limit in 255 bytes.
Example:
from tgbox.tools import CustomAttributes
# Some random types
cattr = CustomAttributes.make(
sha256 = b'\x00'*32,
never = b'gonna give you up'
)
# Defining text message type
cattr = CustomAttributes.make(
type = b'message'
)
Further will be list of types. You may suggest your own, if interested.
Key | Value | Description |
---|---|---|
sha256 | hash | May be used any hashfunc from hashlib |
reply | message.id |
Reply to the ID |
type | b'message' |
Text message type, can be another Value |
from tgbox.
The CustomAttributes
is now a PackedAttributes
. This algorithm is used now for packing metadata attrs. comment
attribute of prepare_file(...)
is now replaced by a cattrs
, user can present a dict with custom file attributes he wants, so all of the previous information on this issue isn't actual as per v1.0.
See new metadata: https://tgbox.readthedocs.io/en/latest/remotebox.html#remoteboxfile
See new cattrs attr: https://tgbox.readthedocs.io/en/latest/tgbox.html?highlight=prepare_file#tgbox.api.DecryptedLocalBox.prepare_file
Still, i want to make a standart for cattrs keys that different apps based on tgbox can share. Like "comment" key to define a file commentary or "type" to define a file type, e.g with a "message" value or even "sha256" / "md5" / "sha1" ... to define a file hash. You can propose your ideas here.
from tgbox.
Related Issues (20)
- Doesn't update LocalBox with asyncio.gather
- Bug on iterating files over RemoteBox
- Test with PyAES
- Better file previews HOT 1
- Add ability to decrypt EncryptedRemoteBoxFile without RemoteBox HOT 1
- Independence from Telegram HOT 1
- English language HOT 1
- Add logging HOT 1
- PyTest
- Investigate pyaesni HOT 2
- Add offset to the fastelethon.py upload/download functions HOT 1
- Try to multiprocess fastelethon.py (upload/download) HOT 1
- Bug with retrieving thumbnail from Telegram file HOT 1
- Windows doesn't close SQL DB file, *LocalBox.delete()
- ReadTheDocs doesn't catch modules HOT 1
- Investigate MariaDB
- LocalBox.sync from the other LocalBox
- Download from specified offset
- Server closed the connection: 0 bytes read on a total of 8 expected bytes HOT 2
- FTP / WebDAV Access HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tgbox.