skip to Main Content

I am using tl-language compiler to compile schema of Telegram Api TL language described in https://core.telegram.org/mtproto in C#

There is a compiler that compile tl-language to C# classes https://github.com/everbytes/SharpTL.Compiler

But it can compile new telegram schema at this line:

"params":[
    {"name":"flags","type":"#"},
    {"name":"report_spam","type":"flags.0?true"}]
,"type":"PeerSettings"}

And it compile it to wrong code:

[TLObject(0x818426CD)]
public partial class PeerSettings : IPeerSettings
{
    [TLProperty(1)]
    public I# Flags { get; set; }

    [TLProperty(2)]
    public IFlags0?true ReportSpam { get; set; }

}

Is there any solution in casting in C# codes?

I do not know what is type of this “flags:#” in C#

This type “#” described in https://core.telegram.org/mtproto/TL-formal

user {flags:#} id:flags.0?string first_name:flags.1?string last_name:flags.2?string reserved3:flags.3?False reserved4:flags.4?False = User flags;

In the future, bits 3 and 4 in the flags field may be used to transmit new fields after changing the names and types of the reserved3 and reserved4 fields

2

Answers


  1. this means int according to TLGenerator

    Login or Signup to reply.
  2. peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings  
    

    deep searching around this I think this hash (#) means that dynamic value of variable, in some cases it can be true or false, another cases it can be a sequence of integers nonnegative:

    matrix {X:Type} m:# n:# a:(%Tuple (%Tuple X m) n) = Matrix X;
    

    above we got the M and N taking a integer random value > 0

    get_users req_fields:# ids:%(Vector int) = Vector %(User req_fields)
    

    in this another case it can assume a conditional value
    req_fields variable is cast only to User object, but in other cases it could be casted
    to another kind of object.

    maybe the correct way of this TLObject in c# is :

    [TLObject(0x818426CD)]
    public partial class PeerSettings : IPeerSettings
    {
        [TLProperty(1)]
        public int Flags { get; set; }
    
        [TLProperty(2)]
        public bool ReportSpam { get; set; }
    
    }
    

    apologises my english is rusty

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search