Git Product home page Git Product logo

go-tl-parser's Introduction

go-tl-parser

Generates JSON or Go structs/methods of a Telegram .tl file Adds every single comment (Structs, Struct members, Methods, Method arguments)

Proof of concept

Here is class defined in Type Language:

//@description The message was originally a post in a channel @chat_id Identifier of the chat from which the message was forwarded @author_signature Post author signature
//@date Point in time (Unix timestamp) when the message was originally sent @message_id Message identifier of the original message from which the new message was forwarded; 0 if unknown
//@forwarded_from_chat_id For messages forwarded to the chat with the current user (saved messages), the identifier of the chat from which the message was forwarded; 0 if unknown
//@forwarded_from_message_id For messages forwarded to the chat with the current user (saved messages), the identifier of the original message from which the new message was forwarded; 0 if unknown
messageForwardedPost chat_id:int53 author_signature:string date:int32 message_id:int53 forwarded_from_chat_id:int53 forwarded_from_message_id:int53 = MessageForwardInfo;

Here is the autogenerated go struct:

// MessageForwardedPost The message was originally a post in a channel
type MessageForwardedPost struct {
	tdCommon
	MessageID              int64  `json:"message_id"`                // Message identifier of the original message from which the new message was forwarded; 0 if unknown
	ForwardedFromChatID    int64  `json:"forwarded_from_chat_id"`    // For messages forwarded to the chat with the current user (saved messages), the identifier of the chat from which the message was forwarded; 0 if unknown
	ForwardedFromMessageID int64  `json:"forwarded_from_message_id"` // For messages forwarded to the chat with the current user (saved messages), the identifier of the original message from which the new message was forwarded; 0 if unknown
	ChatID                 int64  `json:"chat_id"`                   // Identifier of the chat from which the message was forwarded
	AuthorSignature        string `json:"author_signature"`          // Post author signature
	Date                   int32  `json:"date"`                      // Point in time (Unix timestamp) when the message was originally sent
}

Usage

Install by running:

$ go get github.com/Arman92/go-tl-parser

Run by:

$ go-tl-parser file=./schema.tl dir=./tdlib package=tdlib structs-file=types.go methods-file=methods.go

This work is used in Telegram Tdlib go binding project, used to generate types and functions from .tl schema file, so you may want to change the code to meet your needs.

Files under tdlib folder are autogenerated (except tdjson.go which is only there for error-free compliation)

Credits for basic c-bindings goes to go-tdjson

Type Language .tl schema for tdlib can be found here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.