TLSharp/TeleSharp.TL/TL/TLDraftMessage.cs

58 lines
1.7 KiB
C#
Raw Normal View History

2016-09-24 15:38:26 +02:00
using System.IO;
2017-04-13 08:38:01 +02:00
2016-09-24 15:38:26 +02:00
namespace TeleSharp.TL
{
2017-04-13 08:38:01 +02:00
[TLObject(-40996577)]
2016-09-24 15:38:26 +02:00
public class TLDraftMessage : TLAbsDraftMessage
{
2017-04-13 08:38:01 +02:00
public override int Constructor => -40996577;
2016-09-24 15:38:26 +02:00
2017-04-13 08:38:01 +02:00
public int flags { get; set; }
public bool no_webpage { get; set; }
public int? reply_to_msg_id { get; set; }
public string message { get; set; }
public TLVector<TLAbsMessageEntity> entities { get; set; }
public int date { get; set; }
2016-09-24 15:38:26 +02:00
2017-04-13 08:38:01 +02:00
public void ComputeFlags()
{
flags = 0;
flags = no_webpage ? flags | 2 : flags & ~2;
flags = reply_to_msg_id != null ? flags | 1 : flags & ~1;
flags = entities != null ? flags | 8 : flags & ~8;
}
2016-09-24 15:38:26 +02:00
public override void DeserializeBody(BinaryReader br)
{
flags = br.ReadInt32();
2017-04-13 08:38:01 +02:00
no_webpage = (flags & 2) != 0;
if ((flags & 1) != 0)
reply_to_msg_id = br.ReadInt32();
else
reply_to_msg_id = null;
message = StringUtil.Deserialize(br);
if ((flags & 8) != 0)
entities = ObjectUtils.DeserializeVector<TLAbsMessageEntity>(br);
else
entities = null;
date = br.ReadInt32();
2016-09-24 15:38:26 +02:00
}
public override void SerializeBody(BinaryWriter bw)
{
2017-04-13 08:38:01 +02:00
bw.Write(Constructor);
2016-09-24 15:38:26 +02:00
ComputeFlags();
2017-04-13 08:38:01 +02:00
bw.Write(flags);
if ((flags & 1) != 0)
bw.Write(reply_to_msg_id.Value);
StringUtil.Serialize(message, bw);
if ((flags & 8) != 0)
ObjectUtils.SerializeObject(entities, bw);
bw.Write(date);
2016-09-24 15:38:26 +02:00
}
}
2017-04-13 08:38:01 +02:00
}