mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 03:13:45 +03:00
Improve autogenerated examples with more cases and synonyms
This commit is contained in:
parent
34879a4b35
commit
932d3bd033
|
@ -2,10 +2,6 @@ import re
|
||||||
|
|
||||||
|
|
||||||
KNOWN_NAMED_EXAMPLES = {
|
KNOWN_NAMED_EXAMPLES = {
|
||||||
('peer', 'InputPeer'): "'TelethonOffTopic'",
|
|
||||||
('channel', 'InputChannel'): "'TelethonOffTopic'",
|
|
||||||
('user_id', 'InputUser'): "'Lonami'",
|
|
||||||
('users', 'InputUser'): "'Lonami'",
|
|
||||||
('message', 'string'): "'Hello there!'",
|
('message', 'string'): "'Hello there!'",
|
||||||
('expires_at', 'date'): 'datetime.timedelta(minutes=5)',
|
('expires_at', 'date'): 'datetime.timedelta(minutes=5)',
|
||||||
('until_date', 'date'): 'datetime.timedelta(days=14)',
|
('until_date', 'date'): 'datetime.timedelta(days=14)',
|
||||||
|
@ -24,7 +20,8 @@ KNOWN_NAMED_EXAMPLES = {
|
||||||
('system_lang_code', 'string'): "'en'",
|
('system_lang_code', 'string'): "'en'",
|
||||||
('lang_pack', 'string'): "''",
|
('lang_pack', 'string'): "''",
|
||||||
('lang_code', 'string'): "'en'",
|
('lang_code', 'string'): "'en'",
|
||||||
('chat_id', 'int'): '478614198'
|
('chat_id', 'int'): '478614198',
|
||||||
|
('client_id', 'long'): 'random.randrange(-2**63, 2**63)'
|
||||||
}
|
}
|
||||||
|
|
||||||
KNOWN_TYPED_EXAMPLES = {
|
KNOWN_TYPED_EXAMPLES = {
|
||||||
|
@ -37,7 +34,17 @@ KNOWN_TYPED_EXAMPLES = {
|
||||||
'double': '7.13',
|
'double': '7.13',
|
||||||
'Bool': 'False',
|
'Bool': 'False',
|
||||||
'true': 'True',
|
'true': 'True',
|
||||||
'InputChatPhoto': "client.upload_file('/path/to/photo.jpg')"
|
'InputChatPhoto': "client.upload_file('/path/to/photo.jpg')",
|
||||||
|
'InputFile': "client.upload_file('/path/to/file.jpg')",
|
||||||
|
'InputPeer': "'username'"
|
||||||
|
}
|
||||||
|
|
||||||
|
SYNONYMS = {
|
||||||
|
'InputUser': 'InputPeer',
|
||||||
|
'InputChannel': 'InputPeer',
|
||||||
|
'InputDialogPeer': 'InputPeer',
|
||||||
|
'InputNotifyPeer': 'InputPeer',
|
||||||
|
'InputMessage': 'int'
|
||||||
}
|
}
|
||||||
|
|
||||||
# These are flags that are cleaner to leave off
|
# These are flags that are cleaner to leave off
|
||||||
|
@ -196,7 +203,8 @@ class TLArg:
|
||||||
return
|
return
|
||||||
|
|
||||||
known = (KNOWN_NAMED_EXAMPLES.get((self.name, self.type))
|
known = (KNOWN_NAMED_EXAMPLES.get((self.name, self.type))
|
||||||
or KNOWN_TYPED_EXAMPLES.get(self.type))
|
or KNOWN_TYPED_EXAMPLES.get(self.type)
|
||||||
|
or KNOWN_TYPED_EXAMPLES.get(SYNONYMS.get(self.type)))
|
||||||
if known:
|
if known:
|
||||||
f.write(known)
|
f.write(known)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user