Coder Social home page Coder Social logo

servatom / notion-discordbot Goto Github PK

View Code? Open in Web Editor NEW
74.0 1.0 15.0 2.65 MB

A discord bot consuming Notion API to add, retrieve data to Notion databases.

Home Page: https://discord.com/api/oauth2/authorize?client_id=859893575227670528&permissions=274877910016&scope=bot

License: MIT License

Python 98.48% Shell 0.15% Dockerfile 1.34% Procfile 0.03%
discord-bot notion-api notion-database python3 docker heroku-deployment heroku google-drive hacktoberfest

notion-discordbot's Introduction

Notion-DiscordBot

Build StatusVisits Badge

A discord bot consuming Notion API to add and retrieve data from Notion databases.




Instructions to use the bot:

Invite the bot using Bot Invite Link and run *setup

To self-host the bot, read SETUP.md.


Creating Notion Database:

  1. Go to Notion and create a new Integration. Note the internal Integration.

  2. Then in Notion create in a new page create a table like this (Tag being optional field):

4 columns where:

  • Contributor is of property type Title
  • URL of url type
  • Title of text type
  • Tag of multi-select type
  1. Click on the three dots and press Open as page


  1. Then press share and copy the URL. The URL will look something like this: https://www.notion.so/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX?v=YYYYYYYYYYYYYYYYYYYYYYYYY

Note down the X part of the url (RED part)

This is your database id

  1. Also press share again, press Invite and then click on the integration you made earlier

Bot Usage:

  1. Setup
  2. Add Record
  3. Search
  4. Delete
  5. Upload Files
  6. Change Prefix

Setup Bot:

Run *setup command and enter notion api key (the one you got after creating integration) and notion database id.


Adding Record:

*add <URL_YOU_WANT_TO_RECORD> => This will add a new record to your database (if tagging is enabled, it will add a misc tag)

*add <URL_YOU_WANT_TO_RECORD> <TAG> => This will add a new record to your database with the <TAG> tag

For multiple tags: *add <URL_YOU_WANT_TO_RECORD> <TAG>,<TAG1>,<TAG2>

Example:

Sample database populated by the bot:

Searching Record through tags:

*search <Tag1>

For multiple tags: /search <Tag1> <Tag2>.....<TagN>

Searching Record through title:

*title <title>

Example:

Deleting Record through tags:

*delete <Tag 1>

For multiple tags: *delete <Tag 1> <Tag2>......<Tag N>

Deleting Record through title:

*delete <title>

Example:

Uploading files

NOTE: In the below images the prefix used is: *

You can upload any file to the notion database. It can be a pdf, png, jpeg etc.
Here a png file is being uploaded

  1. Drag your file to the chat in discord, add comment to the file you uploaded


Here servatom is tag for the file.

  1. It will then ask the title of the file you uploaded:


  1. The database will be updated:


Changing Prefix

To change the bot prefix, type *prefix, * being the deault prefix.




🎓 All maintainers in this project are under-graduate students in the Department of Computer Science and Engineering, TIET @ Thapar University

👦 Raghav Sharma
      Email: [email protected]
      GitHub: @raghavTinker

👩 Rupanshi Jain
      Email: [email protected]
      GitHub: @rdotjain

Special thanks to Animesh Gupta for giving us better ideas to make this project better and for spreading the word.

notion-discordbot's People

Contributors

jmakhack avatar nayan2306 avatar raghavtinker avatar rdotjain avatar yash22arora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

notion-discordbot's Issues

Code Refactoring

Making the code base more cleaner and making future feature additions and debugging easier for developers

Create tests for the bot

Create simple tests for the bot. Mainly to verify the API calls that are going to Notion. This is to make the Travis-ci integration useful. This will also let us know if something changed in the Notion API

Persistent Storage for docker containers

To prevent duplication of pdf links the file tracker dataUploaded.txt was created that keeps of links. But after restarting the container the file becomes clean. To prevent this, the txt file must be in a persistent volume.

New setup - Prefix not working

Hi,

First of all thanks for your hard work. However I recently updated my docker image and since then it has been really hard to run the bot, (old docker compose below).
I just saw there is a new setup command that can be run from discord, so I guess no need to use DATABASE_TOKEN and AUTH_KEY as environment variables anymore. So I removed them from my docker compose and then the annoying stuff happened. Every time I restart my container I have to run the setup command, the prefix does not work I have to use * everywhere instead of !. ( See screen attached below). I would personally prefer the notion's integration app as environment variable that is probably more secure than discord. Maybe in the future it could be prompted only when the user does not provide it as env 🤷‍♂️.

Thanks for your time, and hope you will be able to fix those issues and update the README file.

Regards

---
version: "3.4"

services:
  notiondiscordbot:
    image: servatom/notiondiscordbot
    container_name: notiondiscordbot
    restart: unless-stopped
    environment:
      - PUID=1000 
      - PGID=1000 
      - TZ=Europe/Paris
      - DATABASE_TOKEN=...  # Can be removed
      - AUTH_KEY=...               # Can be removed
      - DISCORD_AUTH=...      # Need to be change to TOKEN
      - GDRIVE_FOLDER=...
      - PREFIX=!
    volumes:
      - /user/docker/notion-data:/Bot/creds
    security_opt:
      - no-new-privileges:true

prefix-bug

[Feature Request] A switch command to add data continuously when switch is on

As suggested with @daemon1024.

Idea

/saveurl on

From here on whatever URLs are shared the links are kept in the database. Yeah will need to clean up 
things regularly, but still would be convenient 

Things that can be implemented

  • A switch command to switch on the bot to listen on a particular server/channel every time.
  • Delete command to delete previous messages containing links.

Error when adding an item to the db

Hi I just tried to install properly the bot via docker / and in a local env but I'm getting the same error everytime I run the add cmd:

Ignoring exception in command add:
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "bot.py", line 36, in add
    if((doesItExist(url) == False) and (amIThere(url) == False)):
  File "/home/user/notion/Notion-DiscordBot/Bot/duplicateCheck.py", line 31, in amIThere
    with open("./Bot/dataUploaded.txt") as log:
FileNotFoundError: [Errno 2] No such file or directory: './Bot/dataUploaded.txt'

I decided to remove the "Bot/" in line 31 in Bot/duplicateCheck.py
I replaced with open("./Bot/dataUploaded.txt") as log: to with open("./dataUploaded.txt") as log: and now everything is working fine.

Regards

Use multi-select property for "tag"

"tag" property in Notion database currently uses rich-text; change it to multi-select. If the tag already exists in db, assign the tag else create one.

I can't run it

I have installed all the requeriments, but when i try to run, i get that error
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.