help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
slack-bot-assistant
/
bot
RSK World
slack-bot-assistant
Slack Bot Assistant - Python + Slack API + SQLite + PHP Dashboard + Bot Commands + Automation
bot
  • __pycache__
  • app.py30.8 KB
  • config.py1.9 KB
  • helpers.py5.5 KB
  • models.py4.4 KB
  • scheduler.py3.1 KB
  • utils.py12.6 KB
models.py
bot/models.py
Raw Download
Find: Go to:
"""
Slack Bot Assistant - Database Models
Developer: Molla Samser (Founder, RSK World)
Design & Testing: Rima Khatun
Website: https://rskworld.in
Contact: hello@rskworld.in | +91 93305 39277
Year: 2026
"""

from sqlalchemy import create_engine, Column, Integer, String, Text, DateTime, Boolean, Float
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from datetime import datetime
from config import Config

Base = declarative_base()

class UserConfig(Base):
    """Store user preferences and settings"""
    __tablename__ = 'user_configs'
    
    id = Column(Integer, primary_key=True)
    user_id = Column(String(50), unique=True, nullable=False, index=True)
    personality = Column(String(20), default="Professional")
    language = Column(String(20), default="English")
    timezone = Column(String(50), default="UTC")
    created_at = Column(DateTime, default=datetime.utcnow)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

class Reminder(Base):
    """Store user reminders"""
    __tablename__ = 'reminders'
    
    id = Column(Integer, primary_key=True)
    user_id = Column(String(50), nullable=False, index=True)
    channel_id = Column(String(50))
    message = Column(Text, nullable=False)
    reminder_time = Column(DateTime, nullable=False, index=True)
    is_completed = Column(Boolean, default=False)
    created_at = Column(DateTime, default=datetime.utcnow)

class Task(Base):
    """Store tasks created by users"""
    __tablename__ = 'tasks'
    
    id = Column(Integer, primary_key=True)
    user_id = Column(String(50), nullable=False, index=True)
    channel_id = Column(String(50))
    title = Column(String(200), nullable=False)
    description = Column(Text)
    status = Column(String(20), default="pending")  # pending, in_progress, completed, cancelled
    priority = Column(String(20), default="medium")  # low, medium, high, urgent
    due_date = Column(DateTime)
    created_at = Column(DateTime, default=datetime.utcnow)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

class MeetingSummary(Base):
    """Store meeting summaries"""
    __tablename__ = 'meeting_summaries'
    
    id = Column(Integer, primary_key=True)
    channel_id = Column(String(50), nullable=False, index=True)
    summary = Column(Text, nullable=False)
    participant_count = Column(Integer, default=0)
    message_count = Column(Integer, default=0)
    created_by = Column(String(50))
    created_at = Column(DateTime, default=datetime.utcnow, index=True)

class MessageSentiment(Base):
    """Store sentiment analysis data for analytics"""
    __tablename__ = 'message_sentiments'
    
    id = Column(Integer, primary_key=True)
    user_id = Column(String(50), index=True)
    channel_id = Column(String(50), index=True)
    message = Column(Text)
    sentiment = Column(String(20))  # POSITIVE, NEGATIVE, NEUTRAL, URGENT
    sentiment_score = Column(Float)
    created_at = Column(DateTime, default=datetime.utcnow, index=True)

class CommandHistory(Base):
    """Store command usage history for analytics"""
    __tablename__ = 'command_history'
    
    id = Column(Integer, primary_key=True)
    user_id = Column(String(50), index=True)
    channel_id = Column(String(50), index=True)
    command = Column(String(50), nullable=False)
    parameters = Column(Text)
    created_at = Column(DateTime, default=datetime.utcnow, index=True)

class Poll(Base):
    """Store polls created by users"""
    __tablename__ = 'polls'
    
    id = Column(Integer, primary_key=True)
    channel_id = Column(String(50), nullable=False, index=True)
    created_by = Column(String(50), nullable=False)
    question = Column(Text, nullable=False)
    options = Column(Text, nullable=False)  # JSON string
    votes = Column(Text)  # JSON string storing user_id -> option_index
    is_active = Column(Boolean, default=True)
    created_at = Column(DateTime, default=datetime.utcnow, index=True)
    expires_at = Column(DateTime)

# Database initialization
engine = create_engine(Config.DATABASE_URL, echo=False)
SessionLocal = sessionmaker(bind=engine)

def init_db():
    """Initialize database tables"""
    Base.metadata.create_all(engine)

def get_db():
    """Get database session"""
    db = SessionLocal()
    try:
        return db
    finally:
        pass  # Don't close here, let caller manage

122 lines•4.4 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer