Refactor SyncCore

This commit is contained in:
Peter
2019-10-21 16:58:00 +04:00
parent 75aa77faa8
commit 10692a323e
1162 changed files with 12205 additions and 10925 deletions

View File

@@ -0,0 +1,45 @@
import Postbox
public struct BotCommand: PostboxCoding, Hashable {
public let text: String
public let description: String
public init(text: String, description: String) {
self.text = text
self.description = description
}
public init(decoder: PostboxDecoder) {
self.text = decoder.decodeStringForKey("t", orElse: "")
self.description = decoder.decodeStringForKey("d", orElse: "")
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeString(self.text, forKey: "t")
encoder.encodeString(self.description, forKey: "d")
}
}
public final class BotInfo: PostboxCoding, Equatable {
public let description: String
public let commands: [BotCommand]
public init(description: String, commands: [BotCommand]) {
self.description = description
self.commands = commands
}
public init(decoder: PostboxDecoder) {
self.description = decoder.decodeStringForKey("d", orElse: "")
self.commands = decoder.decodeObjectArrayWithDecoderForKey("c")
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeString(self.description, forKey: "d")
encoder.encodeObjectArray(self.commands, forKey: "c")
}
public static func ==(lhs: BotInfo, rhs: BotInfo) -> Bool {
return lhs.description == rhs.description && lhs.commands == rhs.commands
}
}