TweetupKit

TweetupKit 是一个 Swift 库,它帮助在 Twitter 上进行演示。它解析以类似于 Markdown 格式编写的演示文稿脚本。解析后的推文会自动以恒定间隔发布。

let speaker = Speaker(
    twitterCredential: twitterCredential,
    githubToken: githubToken,
    outputDirectoryPath: imageDirectoryPath
)

let tweetsString = """
    Twinkle, twinkle, little star,
    How I wonder what you are!

    ---

    Up above the world so high,
    Like a diamond in the sky.

    ```swift:hello.swift
    let name = "Swift"
    print("Hello \\(name)!")
    ```

    ---

    Twinkle, twinkle, little star,
    How I wonder what you are!

    ![](\(imagePath))
    """

let tweets = try! Tweet.tweets(from: tweetsString)
speaker.post(tweets: tweets, interval: 10.0).get { getResponses in
    let responses = try getResponses()
    for response in responses {
        print("\(response.statusId), \(response.screenName)")
    }
}

推文格式

Tweets can be written in a format similar to Markdown like this.
Each tweet is separated by ---.

---

Tweets can contain code. TweetupKit creates a Gist of the code,
and a link to the Gist and a screenshot of the code are posted together.

```swift:hello.swift
let name = "Swift"
print("Hello \(name)!")
```

---

Also images can be attached to tweets.

![](path/to/image)

安装

Swift Package Manager 可用。

.package(
    url: "https://github.com/swift-tweets/tweetup-kit.git",
    from: "0.2.0"
)