package upconv

import 

func ( *tg.Message,  tg.UpdatesClass) {
	if ,  := .(interface {
		() (tg.MessageFwdHeader, bool)
	});  {
		if ,  := .();  {
			.SetFwdFrom()
		}
	}
	if ,  := .(interface{ () (int64, bool) });  {
		if ,  := .();  {
			.SetViaBotID()
		}
	}
	if ,  := .(interface {
		() (tg.MessageReplyHeader, bool)
	});  {
		if ,  := .();  {
			.SetReplyTo(&)
		}
	}
	if ,  := .(interface {
		() ([]tg.MessageEntityClass, bool)
	});  {
		if ,  := .();  {
			.SetEntities()
		}
	}
	if ,  := .(interface {
		() (tg.MessageMediaClass, bool)
	});  {
		if ,  := .();  {
			.SetMedia()
		}
	}
}

// ShortMessage converts UpdateShortMessage to UpdateShort.
func ( *tg.UpdateShortMessage) *tg.UpdateShort {
	 := &tg.Message{
		ID:      .ID,
		PeerID:  &tg.PeerUser{UserID: .UserID},
		Message: .Message,
		Date:    .Date,
	}
	// Optional fields should set by SetXXX(), so GetXXX and Flags.Has()
	// can return the right values even we hav't call .Encode()
	.SetOut(.Out)
	.SetMentioned(.Mentioned)
	.SetMediaUnread(.MediaUnread)
	.SetSilent(.Silent)

	if !.Out {
		.SetFromID(&tg.PeerUser{UserID: .UserID})
	}
	convertOptional(, )

	return &tg.UpdateShort{
		Update: &tg.UpdateNewMessage{
			Message:  ,
			Pts:      .Pts,
			PtsCount: .PtsCount,
		},
		Date: .Date,
	}
}

// ShortChatMessage converts UpdateShortChatMessage to UpdateShort.
func ( *tg.UpdateShortChatMessage) *tg.UpdateShort {
	 := &tg.Message{
		ID:      .ID,
		PeerID:  &tg.PeerChat{ChatID: .ChatID},
		Message: .Message,
		Date:    .Date,
	}

	.SetFromID(&tg.PeerUser{UserID: .FromID})
	.SetOut(.Out)
	.SetMentioned(.Mentioned)
	.SetMediaUnread(.MediaUnread)
	.SetSilent(.Silent)

	convertOptional(, )

	return &tg.UpdateShort{
		Update: &tg.UpdateNewMessage{
			Message:  ,
			Pts:      .Pts,
			PtsCount: .PtsCount,
		},
		Date: .Date,
	}
}

// ShortSentMessage converts UpdateShortSentMessage to UpdateShort.
func ( *tg.UpdateShortSentMessage) *tg.UpdateShort {
	 := &tg.Message{
		ID:   .ID,
		Date: .Date,
	}
	.SetOut(.Out)
	convertOptional(, )

	return &tg.UpdateShort{
		Update: &tg.UpdateNewMessage{
			Message:  ,
			Pts:      .Pts,
			PtsCount: .PtsCount,
		},
		Date: .Date,
	}
}