darchivev3

package
v0.0.0-...-228b61a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2020 License: Unlicense Imports: 3 Imported by: 0

README

Version 3 of Darchive

In V3 all contents are stored in a json file that may optionally be GZipped It stores the date and channel of the archive and a list of messages within the archive

Be aware that the array of messages are in reverse order as compared to how they are displayed in chat, the top of the array contains the newest message and the bottom of the array contains the oldest message

The structs used for messages, channels, and users, are fairly typical to discord and are for the most part directly comparable to the data layout for messages used by discord itself

Documentation

Index

Constants

View Source
const PackVersion int = 3

PackVersion is the version of the archive format, would be more accurately referred to as formatVersion but darchive v3 is already frozen

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveData

type ArchiveData struct {
	PackVersion Version   `json:"packVersion"` // note that via the data type this will always be marshaled to 4
	Date        time.Time `json:"timestamp"`

	Messages []*Message `json:"messages,omitempty"`
	Channel  *Channel   `json:"channel"`
}

ArchiveData contains the channel archive information

type ArchiveDataEncoding

type ArchiveDataEncoding struct {
	PackVersion Version   `json:"packVersion"`
	Date        time.Time `json:"timestamp"`

	Messages json.RawMessage `json:"messages,omitempty"`
	Channel  *Channel        `json:"channel"`
}

ArchiveDataEncoding is an alternate version of ArchiveData that replaces the Messages field with a json.RawMessage for manual constructing of the messages json, used in the mojitree archiver to be able to build the messages field in chunks instead of all at once

type Channel

type Channel struct {
	ID               string                `json:"id"`
	GuildID          string                `json:"guild_id,omitempty"`
	Name             string                `json:"name"`
	Topic            string                `json:"topic"`
	Type             discordgo.ChannelType `json:"type"`
	NSFW             bool                  `json:"nsfw"`
	ParentID         string                `json:"parent_id"`
	RateLimitPerUser int                   `json:"rate_limit_per_user"`
}

Channel is the channel data saved by darchive v3

func DgoToDcChannel

func DgoToDcChannel(dg *discordgo.Channel) *Channel

DgoToDcChannel converts a discordgo channel struct to a darchive one

func DgoToDcChannels

func DgoToDcChannels(dg []*discordgo.Channel) []*Channel

DgoToDcChannels converts a slice of discordgo channels to a slice of darchive ones

type Message

type Message struct {
	ID        string `json:"id,omitempty"`
	ChannelID string `json:"channel_id,omitempty"`
	GuildID   string `json:"guild_id,omitempty"`
	Content   string `json:"content,omitempty"`

	Timestamp       discordgo.Timestamp `json:"timestamp,omitempty"`
	EditedTimestamp discordgo.Timestamp `json:"edited_timestamp,omitempty"`

	TTS    bool `json:"tts"`
	Pinned bool `json:"pinned"`

	MentionRoles    []string   `json:"mention_roles,omitempty"`
	MentionEveryone bool       `json:"mention_everyone"`
	MentionUsers    []*User    `json:"mention_users,omitempty"`
	MentionChannels []*Channel `json:"mention_channels,omitempty"`

	Author *User `json:"author,omitempty"`

	Attachments []*discordgo.MessageAttachment `json:"attachments,omitempty"`
	Embeds      []*discordgo.MessageEmbed      `json:"embeds,omitempty"`
	Reactions   []*discordgo.MessageReactions  `json:"reactions,omitempty"`

	Type discordgo.MessageType `json:"type"`

	WebhookID string `json:"webhook_id,omitempty"`

	Activity *discordgo.MessageActivity `json:"activity,omitempty"`

	Application *discordgo.MessageApplication `json:"application,omitempty"`

	MessageReference *discordgo.MessageReference `json:"message_reference,omitempty"`

	Flags discordgo.MessageFlags `json:"flags"`
}

Message is the message information saved and encoded by darchive v3

func DgoToDcMessage

func DgoToDcMessage(dg *discordgo.Message) *Message

DgoToDcMessage converts a Discordgo message struct to the message struct used by the archiver

func DgoToDcMessages

func DgoToDcMessages(dg []*discordgo.Message) []*Message

DgoToDcMessages converts a list of Discordgo message structs to the message struct used by the archiver

type User

type User struct {
	ID            string `json:"id"`
	Username      string `json:"username"`
	Avatar        string `json:"avatar"`
	Discriminator string `json:"discriminator"`
	Bot           bool   `json:"bot"`
}

User is the user data saved by darchive v3

func DgoToDcUser

func DgoToDcUser(dg *discordgo.User) *User

DgoToDcUser converts a Discordgo user struct to the darchive user struct

func DgoToDcUsers

func DgoToDcUsers(dg []*discordgo.User) []*User

DgoToDcUsers is like DgoToDcUser except plural, it takes a list of users

type Version

type Version int

Version is just an int that always marshals to the FormatVersion, in this case 3

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

MarshalJSON marshals 3 in json

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL