Mercurial > prosody-modules
annotate mod_captcha_registration/install.lua @ 4579:b305814bd930
mod_muc_dicebot: A thing to roll dice
Do you see what happens, Jitsi? Do you see what happens when you
make it hard for me to use a proper bot? This is what happens,
Jitsi. This is what happens when you meet a stranger in the alps!
Ahem. In all seriousness, this is more of a quick hack than
anything else. It will look for `.r` in MUC messages and if it
finds it, it'll interpret it as an instruction to roll a few
dice. Injects the results in the body of the message. Eats the
message alive if it is malformed.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Sat, 29 May 2021 15:17:05 +0200 |
parents | 985bfc6e8cad |
children |
rev | line source |
---|---|
1373
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
1 -- simple installer for mod_register with dependicies |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
2 |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
3 files = {"util/dataforms.lua", "modules/mod_register.lua", "FiraSans-Regular.ttf"} |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
4 |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
5 default_path = "/usr/lib/prosody" |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
6 |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
7 |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
8 function exists(name) |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
9 if type(name) ~= "string" then return false end |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
10 return os.rename(name, name) and true or false |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
11 end |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
12 |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
13 function copy_file(name, target) |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
14 local file = io.open(name) |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
15 local data = file:read("*all") |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
16 file:close() |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
17 local file = io.open(target, "w") |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
18 file:write(data) |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
19 file:close() |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
20 end |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
21 |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
22 function copy_files(path) |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
23 for index = 1, #files do |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
24 local filename = files[index] |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
25 os.remove(default_path.."/"..filename) |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
26 copy_file(filename, default_path.."/"..filename) |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
27 print("copied: "..default_path.."/"..filename) |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
28 end |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
29 end |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
30 |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
31 if not exists(default_path) then |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
32 io.write("\nEnter prosody path [/usr/lib/prosody]: ") |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
33 path = io.read("*line") |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
34 end |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
35 |
985bfc6e8cad
mod_captcha_registration: initial commit
mrDoctorWho <mrdoctorwho@gmail.com>
parents:
diff
changeset
|
36 copy_files(path or default_path) |