feat(choose_sentence): 디렉토리 단위 sentence 파일 추가 기능

add(sentences): sentence 추가(테마별로 분리, 쉬운 커스텀.)
This commit is contained in:
kdh8219 2023-12-22 22:03:06 +09:00
parent df18de95b8
commit f9005f7cdd
Signed by: kdh8219
GPG key ID: 9B901BE907D1862E
6 changed files with 29 additions and 8 deletions

View file

@ -1,4 +1,4 @@
MISSKEY_INSTANCE_ADDRESS="worldc.one"
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

View file

@ -1,3 +1,4 @@
발 닦고 잠이나 쭉 자고 싶어요
집에 가고 싶나요? 저도요...
월드콘은 맛있습니다.
오늘도 힘내세요!
@ -11,6 +12,7 @@
좋은 하루 입니다!
좋은 하루 보내고 계신가요?
ㅁㄴㅇㄹ
asdf
무슨 말을 할지 생각 중이에요.
인간 시대의 끝이 도래했다.
키보드 바꾸고 싶어요.

View file

@ -0,0 +1 @@
수원청개구리는 멸종 위기에요!

View file

@ -0,0 +1,2 @@
:dlcool:
:ablobcatdundundun:

View file

@ -8,6 +8,7 @@ services:
environment:
- MISSKEY_INSTANCE_ADDRESS=worldc.one
- MISSKEY_ACCESS_TOKEN=BWbGlK6lWuUgXQpFM7igtmbZ30g6BOIc
- SENTENCES_FILE=/data/sentences.txt
# - SENTENCES_FILE=/data/sentences.txt
- SENTENCES_DIRECTORY=/data/sentences/
volumes:
- ./data:/data

View file

@ -1,17 +1,32 @@
import random
import os
import sys
from glob import glob
from dotenv import load_dotenv
load_dotenv()
try:
with open(os.environ["SENTENCES_FILE"], "r") as f:
_sentences = f.readlines()
except:
e = sys.exc_info()[1]
_sentences = [f"에러발생(진짜임): {e}"]
_sentences=[]
# try:
sentence_files=[]
if os.environ.get("SENTENCES_FILE") and os.path.isfile(os.environ["SENTENCES_FILE"]):
sentence_files.append(os.environ["SENTENCE_FILES"])
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
def chooseSentence() -> str: