Compare commits
No commits in common. "b049f0a152c5899fb2d156881af380945885a40c" and "12b74d54fbf010a0e4fb5403029e157fb73455f1" have entirely different histories.
b049f0a152
...
12b74d54fb
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"s": "Головна сторінка сервера: http://10.1.1.1:12010/",
|
"s": "Головна сторінка сервера: http://10.1.1.1:12010/",
|
||||||
"ss": "Головна сторінка сервера: http://10.1.1.1:12010/",
|
"ss": "Головна сторінка сервера: http://10.1.1.1:12010/",
|
||||||
"u": "Універсальне посилання: http://10.1.1.1:12025/",
|
|
||||||
"пари_для_артема": "🧐",
|
"пари_для_артема": "🧐",
|
||||||
"пари_для_артема_хоч_і_не_на_завтра": "🤨"
|
"пари_для_артема_хоч_і_не_на_завтра": "🤨"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,107 +0,0 @@
|
||||||
import random
|
|
||||||
|
|
||||||
module_path = ""
|
|
||||||
|
|
||||||
def extract_separators(text):
|
|
||||||
sequence_buf = ""
|
|
||||||
seps = []
|
|
||||||
|
|
||||||
for i in text:
|
|
||||||
if i in ["\n", " "]:
|
|
||||||
sequence_buf += i
|
|
||||||
elif sequence_buf:
|
|
||||||
seps.append(sequence_buf)
|
|
||||||
sequence_buf = ""
|
|
||||||
|
|
||||||
return seps
|
|
||||||
|
|
||||||
def process(message, path):
|
|
||||||
if not message.text.lower().startswith("!shuf"):
|
|
||||||
return "", None
|
|
||||||
|
|
||||||
global module_path
|
|
||||||
module_path = path
|
|
||||||
|
|
||||||
cmd = message.text.split()
|
|
||||||
print(cmd)
|
|
||||||
l = len(cmd)
|
|
||||||
|
|
||||||
# settings
|
|
||||||
split_by = "word"
|
|
||||||
shuf_individual_words = False
|
|
||||||
data_source = "reply"
|
|
||||||
only_spaces = False
|
|
||||||
|
|
||||||
shuf_data = []
|
|
||||||
|
|
||||||
i = 1
|
|
||||||
|
|
||||||
# parsing arguments
|
|
||||||
while i < l:
|
|
||||||
print("C", i, cmd[i])
|
|
||||||
if cmd[i][0] != "-" or cmd[i] == "--":
|
|
||||||
break
|
|
||||||
elif cmd[i] == "-i":
|
|
||||||
shuf_individual_words = True
|
|
||||||
elif cmd[i] == "-c":
|
|
||||||
split_by = "char"
|
|
||||||
elif cmd[i] == "-o":
|
|
||||||
only_spaces = True
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
# parsing text (if any)
|
|
||||||
while i < l:
|
|
||||||
print("T", i, cmd[i])
|
|
||||||
data_source = "internal"
|
|
||||||
if split_by == "char":
|
|
||||||
for c in cmd[i]:
|
|
||||||
shuf_data.append(c)
|
|
||||||
shuf_data.append(" ")
|
|
||||||
elif split_by == "word":
|
|
||||||
if shuf_individual_words:
|
|
||||||
shuf_data.append(list(cmd[i]))
|
|
||||||
else:
|
|
||||||
shuf_data.append(cmd[i])
|
|
||||||
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
if data_source == "reply":
|
|
||||||
seps = extract_separators(message['reply_to_message'].text)
|
|
||||||
else:
|
|
||||||
seps = extract_separators(message.text)
|
|
||||||
|
|
||||||
if data_source == "reply":
|
|
||||||
for w in message['reply_to_message'].text.split():
|
|
||||||
if split_by == "char":
|
|
||||||
for c in w:
|
|
||||||
shuf_data.append(c)
|
|
||||||
elif split_by == "word":
|
|
||||||
if shuf_individual_words:
|
|
||||||
shuf_data.append(list(w))
|
|
||||||
else:
|
|
||||||
shuf_data.append(w)
|
|
||||||
|
|
||||||
if split_by == "word":
|
|
||||||
if shuf_individual_words:
|
|
||||||
for w in shuf_data:
|
|
||||||
random.shuffle(w)
|
|
||||||
|
|
||||||
if only_spaces:
|
|
||||||
return " ".join(["".join(w) for w in shuf_data]), "HTML"
|
|
||||||
else:
|
|
||||||
return "".join([i[0] + i[1] for i in zip(["".join(w) for w in shuf_data], seps)]) + "".join(shuf_data[-1]), "HTML"
|
|
||||||
else:
|
|
||||||
random.shuffle(shuf_data)
|
|
||||||
|
|
||||||
if only_spaces:
|
|
||||||
return " ".join(shuf_data), "HTML"
|
|
||||||
else:
|
|
||||||
return "".join([i[0] + i[1] for i in zip(shuf_data, seps)]) + shuf_data[-1], "HTML"
|
|
||||||
elif split_by == "char":
|
|
||||||
if only_spaces:
|
|
||||||
shuf_data += [" " for i in seps]
|
|
||||||
else:
|
|
||||||
shuf_data += seps
|
|
||||||
|
|
||||||
random.shuffle(shuf_data)
|
|
||||||
return "".join(shuf_data), "HTML"
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"start_on_boot": true,
|
|
||||||
"alias": "shuffle",
|
|
||||||
"version": 2,
|
|
||||||
"index_file": "index.py"
|
|
||||||
}
|
|
Loading…
Reference in New Issue