Skip to content

tsdocode/discord-realtime-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

Discord Realtime Analysis

A realtime discord chat analysis and vietnamese hatespeech detection using Keras and Firebase

last update stars


Table of Contents

About the Project

screenshot

Tech Stack

Features

  • Realtime analyze chat in discord channel with Deep Learning
  • Store message and sentiment into Firebase realtime database
  • Realtime report dashboard

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

FIREBASE_KEY : path to Firebase credential json FIREBASE_DB_URL: url of Firebase realtime database TOKENIZER_PATH: path to text tokenizer KERAS_MODEL_PATH: path to bilstm model DISCORD_TOKEN: dev token of discord DISCORD_GUILD: server id

Getting Started

Prerequisites

This project uses miniconda as environment variable, you can use pipenv or something else.

Installation

make install

Run Locally

Clone the project

  git clone https://github.com/tsdocode/discord-realtime-analysis

Go to the project directory

  cd discord-realtime-analysis

Install dependencies

  make install

Start the server

  yarn run

How to?

Train Vietnamese detection using BiLSTM

Dataset

Model

  • BiLSTM

Training metrics

Connect with discord

  • Install discord.py
pip install discord.py
  • Create discord client
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')

client = discord.Client(intents=discord.Intents.all())

Save data to firebase

Everytime get message from user

    text_sentiment = sentiment(text)

    db.push({
        "user" : message.author.name,
        'channel': message.channel.name,
        "content": message.content,
        "sentiment":text_sentiment,
        "time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    }, "/server/message_log")

Load data to dashboard

def get_data():
    db = load_db()
    messages = db.get("server/message_log")

    text = ""

    messages = [messages[i] for i in messages]
    text = " ".join([i["content"] for i in messages])
    messages = pd.DataFrame.from_records(messages)
    messages['time'] = pd.to_datetime(messages['time'])
    messages.set_index('time', inplace=True)
    

    channels = db.get("server/channels")
    members =  db.get("server/members")

    return members, channels, messages, text

Demo picture

Contributer

Contact

Thanh Sang - @linkedin - [email protected]

References

Use this section to mention useful resources and libraries that you have used in your projects.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published