feat(choose_sentence): 디렉토리 단위 sentence 파일 추가 기능
add(sentences): sentence 추가(테마별로 분리, 쉬운 커스텀.)
This commit is contained in:
parent
df18de95b8
commit
f9005f7cdd
|
@ -1,4 +1,4 @@
|
||||||
MISSKEY_INSTANCE_ADDRESS="worldc.one"
|
MISSKEY_INSTANCE_ADDRESS="worldc.one"
|
||||||
MISSKEY_ACCESS_TOKEN="BWbGlK6lWuUgXQpFM7igtmbZ30g6BOIc" # it is just a sample
|
MISSKEY_ACCESS_TOKEN="BWbGlK6lWuUgXQpFM7igtmbZ30g6BOIc" # it is just a sample
|
||||||
|
|
||||||
SENTENCES_FILE="./data/sentences.txt" # Putting an absolute path is recommended
|
SENTENCES_FILE="./data/sentences/sentences.txt" # Putting an absolute path is recommended
|
|
@ -1,3 +1,4 @@
|
||||||
|
발 닦고 잠이나 쭉 자고 싶어요
|
||||||
집에 가고 싶나요? 저도요...
|
집에 가고 싶나요? 저도요...
|
||||||
월드콘은 맛있습니다.
|
월드콘은 맛있습니다.
|
||||||
오늘도 힘내세요!
|
오늘도 힘내세요!
|
||||||
|
@ -11,6 +12,7 @@
|
||||||
좋은 하루 입니다!
|
좋은 하루 입니다!
|
||||||
좋은 하루 보내고 계신가요?
|
좋은 하루 보내고 계신가요?
|
||||||
ㅁㄴㅇㄹ
|
ㅁㄴㅇㄹ
|
||||||
|
asdf
|
||||||
무슨 말을 할지 생각 중이에요.
|
무슨 말을 할지 생각 중이에요.
|
||||||
인간 시대의 끝이 도래했다.
|
인간 시대의 끝이 도래했다.
|
||||||
키보드 바꾸고 싶어요.
|
키보드 바꾸고 싶어요.
|
1
data/sentences/hylasuwon.txt
Normal file
1
data/sentences/hylasuwon.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
수원청개구리는 멸종 위기에요!
|
2
data/sentences/worldcone_custom_emoji.txt
Normal file
2
data/sentences/worldcone_custom_emoji.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
:dlcool:
|
||||||
|
:ablobcatdundundun:
|
|
@ -8,6 +8,7 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- MISSKEY_INSTANCE_ADDRESS=worldc.one
|
- MISSKEY_INSTANCE_ADDRESS=worldc.one
|
||||||
- MISSKEY_ACCESS_TOKEN=BWbGlK6lWuUgXQpFM7igtmbZ30g6BOIc
|
- MISSKEY_ACCESS_TOKEN=BWbGlK6lWuUgXQpFM7igtmbZ30g6BOIc
|
||||||
- SENTENCES_FILE=/data/sentences.txt
|
# - SENTENCES_FILE=/data/sentences.txt
|
||||||
|
- SENTENCES_DIRECTORY=/data/sentences/
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
|
|
|
@ -1,17 +1,32 @@
|
||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
try:
|
_sentences=[]
|
||||||
with open(os.environ["SENTENCES_FILE"], "r") as f:
|
# try:
|
||||||
_sentences = f.readlines()
|
sentence_files=[]
|
||||||
except:
|
if os.environ.get("SENTENCES_FILE") and os.path.isfile(os.environ["SENTENCES_FILE"]):
|
||||||
e = sys.exc_info()[1]
|
sentence_files.append(os.environ["SENTENCE_FILES"])
|
||||||
_sentences = [f"에러발생(진짜임): {e}"]
|
|
||||||
|
if os.environ.get("SENTENCES_DIRECTORY") and os.path.isdir(os.environ["SENTENCES_DIRECTORY"]):
|
||||||
|
sentence_files.extend(glob(f'{os.environ["SENTENCES_DIRECTORY"]}*.txt'))
|
||||||
|
# for (dirpath, dirnames, filenames) in os.walk(os.environ["SENTENCES_DIRECTORY"]):
|
||||||
|
# for filename in filenames:
|
||||||
|
# sentence_files.append(filename)
|
||||||
|
|
||||||
|
print(sentence_files)
|
||||||
|
|
||||||
|
for sentence_file in sentence_files:
|
||||||
|
with open(sentence_file, "r") as f:
|
||||||
|
_sentences.extend(f.readlines())
|
||||||
|
# except:
|
||||||
|
# e = sys.exc_info()[1]
|
||||||
|
# _sentences = [f"에러발생(진짜임): {e}"]
|
||||||
|
|
||||||
# choose random sentence in google spread sheet
|
# choose random sentence in google spread sheet
|
||||||
def chooseSentence() -> str:
|
def chooseSentence() -> str:
|
||||||
|
|
Loading…
Reference in a new issue