diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2f3419a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.7 +WORKDIR /usr/src/app +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt +COPY src . +COPY config.json ./ +CMD [ "python", "bot.py"] diff --git a/README.md b/README.md index a70e364..506e16b 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,6 @@ A bot to hold your todo.txt tasks ## setup and installation -### requirements -- fuzzywuzzy -- telepot - ### install 1. `git clone` the project or download it 2. Create bot with [@botfather](https://t.me/botfather) @@ -17,8 +13,11 @@ A bot to hold your todo.txt tasks , "tasks_file": "./tasks.json" } ``` -4. `cd` to project directory -5. run `bot.py` +4. run `cp docker-compose.example docker-compose.yml` +5. run `mkdir YOUR_TASKS_DIRECTORY` +6. run `echo {} > YOUR_TASKS_DIRECTORY/tasks.json` +7. edit `docker-compose.yml` bot.volumes to match your directory with your tasks +8. run `docker-compose up` ## commands See [help.md](help.md) diff --git a/docker-compose.examle b/docker-compose.examle new file mode 100644 index 0000000..13b650c --- /dev/null +++ b/docker-compose.examle @@ -0,0 +1,8 @@ +version: '3' +services: + bot: + build: ./ + volumes: + - ./tasks:/tasks +volumes: + tasks: diff --git a/bot.py b/src/bot.py similarity index 98% rename from bot.py rename to src/bot.py index 92ae10a..a4c4107 100755 --- a/bot.py +++ b/src/bot.py @@ -22,6 +22,7 @@ PROPERTY_LAST_ARGUMENTS = "last_arguments" CONFIG_FILE = 'config.json' ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +TASKS_FILE="/tasks/tasks.json" with open(CONFIG_FILE) as file: @@ -136,7 +137,7 @@ def get_property(property_name, chat_id): :param chat_id: :return: """ - with open(CONFIG['tasks_file']) as tasks_file: + with open(TASKS_FILE) as tasks_file: info_dict = json.loads(tasks_file.read()) key = property_name + ":" + str(chat_id) @@ -153,13 +154,13 @@ def set_property(property_name, value, chat_id): :param value: :param chat_id: """ - with open(CONFIG['tasks_file']) as tasks_file: + with open(TASKS_FILE) as tasks_file: info_dict = json.loads(tasks_file.read()) key = property_name + ":" + str(chat_id) info_dict[key] = value - with open(CONFIG['tasks_file'], 'w') as tasks_file: + with open(TASKS_FILE, 'w') as tasks_file: info_dict = tasks_file.write(json.dumps(info_dict)) @@ -170,7 +171,7 @@ def get_tasks(chat_id, raw=False): :param raw: Defaults to False, raw returns the tasks as strings :return: Returns a python list of tasks, or a python dict if raw is True """ - with open(CONFIG['tasks_file']) as tasks_file: + with open(TASKS_FILE) as tasks_file: tasks_dict = json.loads(tasks_file.read()) if chat_id is None: @@ -224,7 +225,7 @@ def set_tasks(tasks, chat_id): task_dict[chat_id] = plaintext - with open(CONFIG['tasks_file'], 'w+') as tasks_file: + with open(TASKS_FILE, 'w+') as tasks_file: tasks_file.write(json.dumps(task_dict)) diff --git a/src/help.md b/src/help.md new file mode 100644 index 0000000..18e455f --- /dev/null +++ b/src/help.md @@ -0,0 +1,30 @@ +# commands + +Anything sent without a command is assumed to be a new task to be added + +## actions on tasks +- `/add ` - Add a new task +- `/do [id [id [id]...]]` - Do task(s) +- `/priority [id [id [id]...]]` - Set the priority of task(s) +- `/rm [id [id [id]...]]` - Remove task(s) +- `/undo [id [id [id]...]]` - undo task(s) + +### fuzzy actions +- `/fdo ` +- `/fpriority ` +- `/frm ` +- `/fundo ` + +## general +- `/export` - Send all tasks as plaintext +- `/help` - Show help information +- `/ls [filters]` - List tasks +- `/last` - Run the last command sent +- `/marco` - Test if bot is up + + +## /ls filters +- `f[ilter]:` - Tasks must have this text in it +- `!f[ilter]:` - Tasks must **not** have this text in it +- `:show-done` - Show and include done tasks +- `:only-done` - Show only done tasks diff --git a/src/search.py b/src/search.py new file mode 100644 index 0000000..21b35f6 --- /dev/null +++ b/src/search.py @@ -0,0 +1,8 @@ +from fuzzywuzzy import process + +choices = open('tmp').read().split('\n') + +search_term = input('Search term: ') + +for result, matchness in process.extract(search_term, choices): + print(str(matchness), result)