An open API service indexing awesome lists of open source software.

https://github.com/squatboy/gemini-discord-summarizer-bot

discord bot for summarizing discord channel messages using gemini model
https://github.com/squatboy/gemini-discord-summarizer-bot

discord discord-bot discord-py gemini gemini-api python summarize

Last synced: about 1 month ago
JSON representation

discord bot for summarizing discord channel messages using gemini model

Awesome Lists containing this project

README

          

## πŸ‡°πŸ‡· README [ν•œκ΅­μ–΄ 보기](#ν•œκ΅­μ–΄)


# `discord-channelmessage-summarize-bot`

## Intro

a Discord bot that summarizes conversation history in Discord channels using the Google Gemini model. It helps users quickly grasp the essence of long conversations, making it easier to catch up on important information or missed details. It offers both immediate summary via slash commands for specific time ranges and an automatic daily summary feature for a configured channel.

## Deploy

discord-bot-arch

Can be deployed in a cloud environment like above diagram. For 24/7 hosting & smaller-scale deployments, it can be easily configured with free tiers or serverless services, similar to my own setup.

```Use it as a reference only. Design an architecture that best suits your service's scale.```

## Features

* **`Conversation Summarization`:** Summarizes Discord channel message content using the Google Gemini API.
* **`Slash Commands`:** Supports slash commands for instant summarization of messages within specific time ranges (1 hour, 6 hours, 24 hours).
* **`Automatic Daily Summary`:** Automatically summarizes the previous day's conversation in a designated channel at midnight in the configured timezone.
* **`Long Message Splitting`:** Automatically splits long summary results into multiple messages to comply with Discord's message length limits.
* **`Configurable`:** Easy configuration via environment variables for Discord token, Google API key, target channel ID

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

### Prerequisites

* Python 3.8 or higher installed 🐍
* A Discord Bot Application created and the Bot Token πŸ”‘
* Gemini API Key πŸ”‘
> Enable the **Message Content Intent** for your bot in the Discord Developer Portal (under Bot settings) βœ…

### Installation

1. **Clone the repository:**
```bash
git clone https://github.com/squatboy/gemini-discord-summary-bot.git
cd gemini-discord-summary-bot
```

2. **Create a virtual environment (recommended):**
```bash
python -m venv venv
# Windows
.\venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
```

3. **Install dependencies:**
Install the required libraries. You will need a `requirements.txt` file containing the following:
```txt
discord.py
google-generativeai
python-dotenv
pytz
```
```bash
pip install -r requirements.txt
```

## Configuration

You need to create a `.env` file in the project's root directory and set the following environment variables.

### `.env` File Setup

```dotenv
DISCORD_TOKEN=YOUR_DISCORD_BOT_TOKEN
GOOGLE_API_KEY=YOUR_GOOGLE_GEMINI_API_KEY
TARGET_CHANNEL_ID=YOUR_TARGET_CHANNEL_ID_FOR_DAILY_SUMMARY
```

## Commands
screenshot


---






## ν•œκ΅­μ–΄

## μ†Œκ°œ

Discord μ±„λ„μ˜ λŒ€ν™” λ‚΄μš©μ„ Google Gemini λͺ¨λΈμ„ ν™œμš©ν•˜μ—¬ μš”μ•½ν•΄ μ£ΌλŠ” Discord λ΄‡μž…λ‹ˆλ‹€. κΈ΄ λŒ€ν™” λ‚΄μš©μ„ λΉ λ₯΄κ²Œ νŒŒμ•…ν•˜μ—¬ μ€‘μš”ν•œ μ •λ³΄λ‚˜ λ†“μΉœ λ‚΄μš©μ„ μ‰½κ²Œ ν™•μΈν•˜λŠ” 데 도움을 μ€λ‹ˆλ‹€. νŠΉμ • μ‹œκ°„ λ²”μœ„μ˜ λ©”μ‹œμ§€λ₯Ό μ¦‰μ‹œ μš”μ•½ν•˜κ±°λ‚˜, μ„€μ •λœ μ±„λ„μ—μ„œ 맀일 μžλ™μœΌλ‘œ μ „λ‚ μ˜ λŒ€ν™” λ‚΄μš©μ„ μš”μ•½ν•˜λŠ” κΈ°λŠ₯을 μ œκ³΅ν•©λ‹ˆλ‹€.

## 배포
discord-bot-arch

μœ„ λ‹€μ΄μ–΄κ·Έλž¨κ³Ό 같이 ν΄λΌμš°λ“œ ν™˜κ²½μ—μ„œ 배포할 수 있으며, 24/7 ν˜ΈμŠ€νŒ… & μ†Œκ·œλͺ¨μ˜ 경우 μ €λž‘ λΉ„μŠ·ν•˜κ²Œ free tierλ“€λ‘œ κ΅¬μ„±ν•˜κ±°λ‚˜ serverless μ„œλΉ„μŠ€λ“€λ‘œ κ°„λ‹¨ν•˜κ²Œ ꡬ성이 κ°€λŠ₯ν•©λ‹ˆλ‹€

## μ£Όμš” κΈ°λŠ₯

* **λŒ€ν™” μš”μ•½:** Google Gemini APIλ₯Ό μ‚¬μš©ν•˜μ—¬ Discord μ±„λ„μ˜ λ©”μ‹œμ§€ λ‚΄μš©μ„ μš”μ•½ν•©λ‹ˆλ‹€.
* **μŠ¬λž˜μ‹œ μ»€λ§¨λ“œ:** νŠΉμ • μ‹œκ°„(1μ‹œκ°„, 6μ‹œκ°„, 24μ‹œκ°„) λ™μ•ˆμ˜ λ©”μ‹œμ§€λ₯Ό μ¦‰μ‹œ μš”μ•½ν•˜λŠ” μŠ¬λž˜μ‹œ μ»€λ§¨λ“œλ₯Ό μ§€μ›ν•©λ‹ˆλ‹€.
* **μžλ™ 일일 μš”μ•½:** μ„€μ •λœ μ‹œκ°„λŒ€μ˜ μžμ •μ— νŠΉμ • μ±„λ„μ˜ μ „λ‚  λŒ€ν™” λ‚΄μš©μ„ μžλ™μœΌλ‘œ μš”μ•½ν•˜μ—¬ μ „μ†‘ν•©λ‹ˆλ‹€.
* **κΈ΄ λ©”μ‹œμ§€ λΆ„ν• :** μš”μ•½ κ²°κ³Όκ°€ Discord λ©”μ‹œμ§€ 길이 μ œν•œμ„ μ΄ˆκ³Όν•  경우 μžλ™μœΌλ‘œ λΆ„ν• ν•˜μ—¬ μ „μ†‘ν•©λ‹ˆλ‹€.

## μ‹œμž‘ν•˜κΈ°

ν”„λ‘œμ νŠΈλ₯Ό 둜컬 ν™˜κ²½μ—μ„œ μ‹€ν–‰ν•˜κΈ° μœ„ν•œ μ„€μ • λ°©λ²•μž…λ‹ˆλ‹€.
μ½”λ“œ λ‚΄λΆ€ λ‘œμ§μ— λŒ€ν•œ μ„€λͺ… 및 λ©”μ„Έμ§€ μš”μ•½ μ–Έμ–΄λ₯Ό ν•œκ΅­μ–΄λ‘œ μ›ν•˜μ‹œλ©΄
ν”„λ‘œμ νŠΈ λ‚΄λΆ€ 디렉토리 `korean-v1` λ₯Ό μ‚¬μš©ν•˜μ‹œλ©΄ λ©λ‹ˆλ‹€.

### ν•„μˆ˜ 쑰건

* Python 3.8 이상 버전 μ„€μΉ˜ 🐍
* Discord 봇 μ• ν”Œλ¦¬μΌ€μ΄μ…˜ 생성 및 봇 토큰 확보 πŸ”‘
* Gemini API ν‚€ πŸ”‘
* Discord λ΄‡μ˜ λ©”μ‹œμ§€ λ‚΄μš© μΈν…νŠΈ(Message Content Intent) ν™œμ„±ν™” (Discord 개발자 ν¬ν„Έμ—μ„œ 봇 μ„€μ •μ—μ„œ ν™œμ„±ν™”) βœ…

### μ„€μΉ˜

1. **μ €μž₯μ†Œ 클둠:**
```bash
git clone [ν”„λ‘œμ νŠΈ μ €μž₯μ†Œ URL]
cd [ν”„λ‘œμ νŠΈ 폴더]
```

2. **가상 ν™˜κ²½ μ„€μ • (ꢌμž₯):**
```bash
python -m venv venv
# Windows
.\venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
```

3. **쒅속성 μ„€μΉ˜:**
ν”„λ‘œμ νŠΈμ— ν•„μš”ν•œ 라이브러리λ₯Ό μ„€μΉ˜ν•©λ‹ˆλ‹€. μ•„λž˜ λ‚΄μš©μ„ ν¬ν•¨ν•˜λŠ” `requirements.txt` 파일이 ν•„μš”ν•©λ‹ˆλ‹€.
```txt
discord.py
google-generativeai
python-dotenv
pytz
```
```bash
pip install -r requirements.txt
```

## μ„€μ •

ν”„λ‘œμ νŠΈ 루트 디렉토리에 `.env` νŒŒμΌμ„ μƒμ„±ν•˜κ³  λ‹€μŒ ν™˜κ²½ λ³€μˆ˜λ₯Ό μ„€μ •ν•΄μ•Ό ν•©λ‹ˆλ‹€.

### `.env` 파일 μ„€μ •

```dotenv
DISCORD_TOKEN=YOUR_DISCORD_BOT_TOKEN
GOOGLE_API_KEY=YOUR_GOOGLE_GEMINI_API_KEY
TARGET_CHANNEL_ID=YOUR_TARGET_CHANNEL_ID_FOR_DAILY_SUMMARY