-
Notifications
You must be signed in to change notification settings - Fork 0
/
upscale_bot.nim
37 lines (25 loc) · 903 Bytes
/
upscale_bot.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import system
import std/[random, strutils, json]
import xnim
proc readRandomLine*(filename: string): string =
let file = open(filename)
defer: file.close()
var lines = file.readAll().splitLines()
if lines.len == 0:
return ""
randomize()
let randomIndex = rand(lines.len - 1)
# Return the random line
return lines[randomIndex]
let randomLine = readRandomLine("./images.txt")
# This is API Key
const CONSUMER_KEY: string = "GET"
# This is the API secret key
const CONSUMER_SECRET: string = "YOUR"
# This is the Authentication Access Token
const ACCESS_TOKEN: string = "OWN"
# This is the Authentication Access Secret
const TOKEN_SECRET: string = "KEYS"
const xCli: XAPI = newXAPI(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, TOKEN_SECRET)
var mediaId = json.parseJson(xCli.PostMedia(randomLine))["media_id_string"]
let res: string = xCli.PostTextTweet("", @[mediaId.str])