-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnimlangbot.nim
20 lines (14 loc) · 928 Bytes
/
nimlangbot.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import std/[httpclient, strtabs, json, os]
import twitter
const (botUsername, botId) = ("nimlangbot", "1543268386175688704")
proc main() =
assert existsEnv("CONSUMER_KEY") and existsEnv("CONSUMER_SECRET") and existsEnv("ACCESS_TOKEN") and existsEnv("ACCESS_TOKEN_SECRET")
let twitterAPI = newTwitterAPI(getEnv("CONSUMER_KEY"), getEnv("CONSUMER_SECRET"), getEnv("ACCESS_TOKEN"), getEnv("ACCESS_TOKEN_SECRET"))
let data = twitterApi.tweetsSearchRecent("(#nimlang OR nimlang OR nim_lang OR \"nim language\" OR from:nim_lang OR retweets_of:nim_lang) lang:en -malware -virus -is:retweet -is:reply", {"max_results": "100"}.newStringTable).body.parseJson()["data"]
echo "Found the following tweets: "
echo data.pretty()
for tweet in data:
discard twitterApi.usersIdRetweets(botId, %* {"tweet_id": tweet["id"]})
discard twitterApi.usersIdLikes(botId, %* {"tweet_id": tweet["id"]})
when isMainModule:
main()