-
Notifications
You must be signed in to change notification settings - Fork 5
/
tvtropes_post_known.lua
41 lines (36 loc) · 1012 Bytes
/
tvtropes_post_known.lua
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
38
39
40
41
local tvtropes = require "tvtropes"
local tvtropes_post = tvtropes.post
--Function that gets strings from files
local function getdata(filename)
local f=io.open(filename)
if f then
local ret=f:read"*l"
f:close()
return ret
else
return nil
end
end
local handle = getdata "handle"
local passphrase = getdata "passphrase"
if not handle then
io.stdout:write"Enter your troper handle: "
handle = io.stdin:read"*l"
while string.find(handle,"%W") or handle == "" do
print"Handle must be an alphanumeric string."
io.stdout:write"Try again: "
handle = io.stdin:read"*l"
end
end
if not passphrase then
io.stdout:write"Enter your passphrase: "
passphrase = io.stdin:read"*l"
while string.find(passphrase,"%W") or passphrase == "" do
print"Passphrase must be an alphanumeric string."
io.stdout:write"Try again: "
passphrase = io.stdin:read"*l"
end
end
return function (post, body, reason)
return tvtropes_post(post, body, handle, passphrase, reason)
end