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
get_real_videos.pyindex.htmlprocess_images.pyutils.py
index.html
Raw Download
Find: Go to:
<!DOCTYPE html>
<html lang="en">

<head>
    <!-- 
    Slack Bot Assistant - Landing Page
    Developer: Molla Samser (Founder, RSK World)
    Design & Testing: Rima Khatun
    Website: https://rskworld.in
    Contact: hello@rskworld.in | +91 93305 39277
    Year: 2026
    -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Slack Bot Assistant | Productivity Powered by AI</title>
    <meta name="description"
        content="Automate workflows, manage channels, and enhance team collaboration with our AI-powered Slack Bot.">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap" rel="stylesheet">
    <style>
        :root {
            --slack-purple: #4A154B;
            --slack-blue: #36C5F0;
            --slack-green: #2EB67D;
            --slack-yellow: #ECB22E;
            --bg-dark: #0f172a;
            --glass-bg: rgba(255, 255, 255, 0.05);
            --text-primary: #f8fafc;
            --text-secondary: #94a3b8;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Outfit', sans-serif;
        }

        body {
            background-color: var(--bg-dark);
            color: var(--text-primary);
            overflow-x: hidden;
            line-height: 1.6;
        }

        .gradient-bg {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: radial-gradient(circle at 20% 30%, rgba(74, 21, 75, 0.15), transparent),
                radial-gradient(circle at 80% 70%, rgba(54, 197, 240, 0.1), transparent);
            z-index: -1;
        }

        nav {
            padding: 2rem 10%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            backdrop-filter: blur(10px);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .logo {
            font-size: 1.5rem;
            font-weight: 800;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .logo i {
            color: var(--slack-yellow);
        }

        .nav-links {
            display: flex;
            gap: 2rem;
        }

        .nav-links a {
            color: var(--text-secondary);
            text-decoration: none;
            transition: color 0.3s;
            font-weight: 500;
        }

        .nav-links a:hover {
            color: var(--slack-blue);
        }

        .hero {
            padding: 8rem 10% 4rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 4rem;
        }

        .hero-content {
            flex: 1;
        }

        .hero-content h1 {
            font-size: 4rem;
            line-height: 1.1;
            margin-bottom: 2rem;
            background: linear-gradient(to right, #fff, var(--slack-blue));
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .hero-content p {
            font-size: 1.2rem;
            color: var(--text-secondary);
            margin-bottom: 3rem;
            max-width: 600px;
        }

        .btn-group {
            display: flex;
            gap: 1.5rem;
        }

        .btn {
            padding: 1rem 2.5rem;
            border-radius: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            gap: 10px;
        }

        .btn-primary {
            background-color: var(--slack-purple);
            color: white;
            border: none;
            box-shadow: 0 10px 20px rgba(74, 21, 75, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-3px);
            box-shadow: 0 15px 30px rgba(74, 21, 75, 0.4);
        }

        .btn-secondary {
            background-color: transparent;
            color: white;
            border: 2px solid rgba(255, 255, 255, 0.1);
        }

        .btn-secondary:hover {
            background-color: rgba(255, 255, 255, 0.05);
            border-color: rgba(255, 255, 255, 0.2);
        }

        .hero-image {
            flex: 1;
            position: relative;
        }

        .hero-image img {
            width: 100%;
            border-radius: 24px;
            box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
            border: 1px solid rgba(255, 255, 255, 0.1);
            animation: float 6s ease-in-out infinite;
        }

        @keyframes float {

            0%,
            100% {
                transform: translateY(0);
            }

            50% {
                transform: translateY(-20px);
            }
        }

        .features {
            padding: 8rem 10%;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
        }

        .feature-card {
            background: var(--glass-bg);
            padding: 3rem;
            border-radius: 24px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            transition: all 0.3s;
        }

        .feature-card:hover {
            background: rgba(255, 255, 255, 0.08);
            transform: translateY(-10px);
            border-color: var(--slack-blue);
        }

        .feature-card i {
            font-size: 2.5rem;
            margin-bottom: 2rem;
            display: block;
        }

        .feature-card h3 {
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }

        .feature-card p {
            color: var(--text-secondary);
        }

        footer {
            padding: 4rem 10%;
            border-top: 1px solid rgba(255, 255, 255, 0.05);
            text-align: center;
        }

        .footer-details {
            margin-top: 2rem;
            color: var(--text-secondary);
            font-size: 0.9rem;
        }

        @media (max-width: 1024px) {
            .hero {
                flex-direction: column;
                text-align: center;
                padding-top: 4rem;
            }

            .hero-content h1 {
                font-size: 3rem;
            }

            .btn-group {
                justify-content: center;
            }

            .hero-content p {
                margin-left: auto;
                margin-right: auto;
            }
        }
    </style>
</head>

<body>
    <div class="gradient-bg"></div>

    <nav>
        <div class="logo">
            <i class="fab fa-slack"></i>
            <span>BotAssistant</span>
        </div>
        <div class="nav-links">
            <a href="#features">Features</a>
            <a href="demo.html">Live Demo</a>
            <a href="https://rskworld.in" target="_blank">RSK World</a>
        </div>
    </nav>

    <section class="hero">
        <div class="hero-content">
            <h1>Automate Your Team's Success</h1>
            <p>The Slack Bot Assistant provides AI-powered workflow automation, intelligent channel management, and deep
                app integrations to keep your team productive.</p>
            <div class="btn-group">
                <a href="demo.html" class="btn btn-primary">
                    <i class="fab fa-slack"></i> Add to Slack
                </a>
                <a href="#features" class="btn btn-secondary">Explore Features</a>
            </div>
        </div>
        <div class="hero-image">
            <img src="slack-bot-assistant.png" alt="Slack Bot Assistant Preview">
        </div>
    </section>

    <section id="features" class="features">
        <div class="feature-card">
            <i class="fas fa-robot" style="color: var(--slack-blue);"></i>
            <h3>AI Assistance</h3>
            <p>Get instant answers and task management help using our advanced productivity engine.</p>
        </div>
        <div class="feature-card">
            <i class="fas fa-bolt" style="color: var(--slack-yellow);"></i>
            <h3>Workflow Automation</h3>
            <p>Trigger complex workflows directly from Slack with custom shortcuts and slash commands.</p>
        </div>
        <div class="feature-card">
            <i class="fas fa-tasks" style="color: var(--slack-green);"></i>
            <h3>Channel Management</h3>
            <p>Automate archiving, reporting, and member governance across your workspace.</p>
        </div>
    </section>

    <section id="pricing" style="padding: 8rem 10%; text-align: center;">
        <h2 style="font-size: 3rem; margin-bottom: 4rem;">Choose Your Plan</h2>
        <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2rem;">
            <div class="feature-card" style="border: 1px solid rgba(255,255,255,0.05);">
                <h3 style="color: var(--slack-blue);">Free</h3>
                <div style="font-size: 3rem; font-weight: 800; margin: 1rem 0;">$0</div>
                <p style="margin-bottom: 2rem;">Essential bot features for small teams.</p>
                <ul style="list-style: none; text-align: left; margin-bottom: 2rem; color: var(--text-secondary);">
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> Basic Bot Logic</li>
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> 5 Workflows/mo</li>
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> Community Support</li>
                </ul>
                <a href="#" class="btn btn-secondary" style="width: 100%;">Get Started</a>
            </div>
            <div class="feature-card"
                style="border: 2px solid var(--slack-purple); transform: scale(1.05); background: rgba(74, 21, 75, 0.05);">
                <div
                    style="background: var(--slack-purple); color: white; padding: 0.5rem; position: absolute; top: 0; left: 50%; transform: translateX(-50%); border-radius: 0 0 12px 12px; font-size: 0.8rem; font-weight: 600;">
                    MOST POPULAR</div>
                <h3 style="color: var(--slack-purple);">Pro</h3>
                <div style="font-size: 3rem; font-weight: 800; margin: 1rem 0;">$19</div>
                <p style="margin-bottom: 2rem;">Advanced AI for growing businesses.</p>
                <ul style="list-style: none; text-align: left; margin-bottom: 2rem; color: var(--text-secondary);">
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> Sentiment AI</li>
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> Unlimited Workflows</li>
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> Priority Support</li>
                </ul>
                <a href="#" class="btn btn-primary" style="width: 100%;">Go Pro</a>
            </div>
            <div class="feature-card" style="border: 1px solid rgba(255,255,255,0.05);">
                <h3 style="color: var(--slack-yellow);">Enterprise</h3>
                <div style="font-size: 3rem; font-weight: 800; margin: 1rem 0;">Custom</div>
                <p style="margin-bottom: 2rem;">Full customization for enterprises.</p>
                <ul style="list-style: none; text-align: left; margin-bottom: 2rem; color: var(--text-secondary);">
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> Tailored AI Models</li>
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> Dedicated Manager</li>
                    <li><i class="fas fa-check" style="color: var(--slack-green);"></i> 99.9% SLM</li>
                </ul>
                <a href="#" class="btn btn-secondary" style="width: 100%;">Contact Sales</a>
            </div>
        </div>
    </section>

    <section id="faq" style="padding: 8rem 10%; background: rgba(255,255,255,0.02);">
        <h2 style="font-size: 3rem; text-align: center; margin-bottom: 4rem;">Frequently Asked Questions</h2>
        <div style="max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem;">
            <div style="background: var(--glass-bg); padding: 1.5rem; border-radius: 12px; cursor: pointer;">
                <h4 style="display: flex; justify-content: space-between; align-items: center;">
                    How secure is our data? <i class="fas fa-chevron-down"></i>
                </h4>
                <p style="color: var(--text-secondary); margin-top: 1rem;">We use enterprise-grade encryption and comply
                    with global safety standards. Your conversations are private.</p>
            </div>
            <div style="background: var(--glass-bg); padding: 1.5rem; border-radius: 12px; cursor: pointer;">
                <h4 style="display: flex; justify-content: space-between; align-items: center;">
                    Can I customize the bot's features? <i class="fas fa-chevron-down"></i>
                </h4>
                <p style="color: var(--text-secondary); margin-top: 1rem;">Yes! The bot is highly modular. You can add
                    or remove integrations via the admin dashboard.</p>
            </div>
            <div style="background: var(--glass-bg); padding: 1.5rem; border-radius: 12px; cursor: pointer;">
                <h4 style="display: flex; justify-content: space-between; align-items: center;">
                    Is there a mobile app? <i class="fas fa-chevron-down"></i>
                </h4>
                <p style="color: var(--text-secondary); margin-top: 1rem;">Our bot works natively within the Slack
                    mobile app, so you can stay productive anywhere.</p>
            </div>
        </div>
    </section>

    <footer>
        <p>&copy; 2026 Slack Bot Assistant. Part of the RSK World Network.</p>
        <div class="footer-details">
            Developed by <strong>Molla Samser</strong> | Tested by <strong>Rima Khatun</strong><br>
            Contact: hello@rskworld.in | <a href="https://rskworld.in" style="color: inherit;">rskworld.in</a>
        </div>
    </footer>
</body>

</html>
390 lines•14.5 KB
markup
bot/utils.py
Raw Download
Find: Go to:
"""
Slack Bot Assistant - Utilities
Developer: Molla Samser (Founder, RSK World)
Design & Testing: Rima Khatun
Website: https://rskworld.in
Contact: hello@rskworld.in | +91 93305 39277
Year: 2026
"""

import logging
import re
from datetime import datetime, timedelta
from typing import Dict, List, Optional
try:
    from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
    VADER_AVAILABLE = True
except ImportError:
    VADER_AVAILABLE = False
    logging.warning("VADER sentiment analyzer not available, using basic sentiment analysis")

from config import Config

# Setup logging
logging.basicConfig(
    level=getattr(logging, Config.LOG_LEVEL),
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.FileHandler(Config.LOG_FILE),
        logging.StreamHandler()
    ]
)
logger = logging.getLogger(__name__)

# Initialize VADER sentiment analyzer if available
if VADER_AVAILABLE:
    sentiment_analyzer = SentimentIntensityAnalyzer()

def analyze_sentiment(text: str) -> Dict[str, any]:
    """
    Advanced sentiment analysis using VADER or fallback to keyword-based.
    Returns dict with sentiment label and score.
    """
    text_lower = text.lower()
    
    # Enhanced keyword detection
    urgent_keywords = ["urgent", "immediately", "asap", "help", "broken", "critical", "emergency", "down", "error"]
    positive_keywords = ["thanks", "great", "awesome", "good", "solved", "perfect", "excellent", "wonderful", "amazing"]
    negative_keywords = ["bad", "terrible", "worst", "hate", "disappointed", "frustrated", "failed", "broken"]
    
    # Check for urgent keywords first
    if any(word in text_lower for word in urgent_keywords):
        return {"sentiment": "URGENT", "score": 0.9, "confidence": "high"}
    
    # Use VADER if available
    if VADER_AVAILABLE:
        try:
            scores = sentiment_analyzer.polarity_scores(text)
            compound = scores['compound']
            
            if compound >= 0.05:
                return {"sentiment": "POSITIVE", "score": compound, "confidence": "high"}
            elif compound <= -0.05:
                return {"sentiment": "NEGATIVE", "score": abs(compound), "confidence": "high"}
            else:
                return {"sentiment": "NEUTRAL", "score": abs(compound), "confidence": "medium"}
        except Exception as e:
            logger.error(f"Error in VADER sentiment analysis: {e}")
    
    # Fallback to keyword-based analysis
    if any(word in text_lower for word in positive_keywords):
        return {"sentiment": "POSITIVE", "score": 0.7, "confidence": "medium"}
    elif any(word in text_lower for word in negative_keywords):
        return {"sentiment": "NEGATIVE", "score": 0.7, "confidence": "medium"}
    
    return {"sentiment": "NEUTRAL", "score": 0.5, "confidence": "low"}

def get_personality_response(query: str, personality: str = "Professional", language: str = "English") -> str:
    """
    Returns a response based on selected personality and language.
    Enhanced with better sentiment analysis.
    """
    sentiment_data = analyze_sentiment(query)
    sentiment = sentiment_data["sentiment"]
    base_response = ""
    
    # Enhanced response logic based on sentiment
    if sentiment == "URGENT":
        base_response = "I've detected this is urgent. I'm prioritizing your request immediately."
    elif sentiment == "NEGATIVE":
        base_response = "I understand this is concerning. Let me help resolve this quickly."
    elif "status" in query.lower() or "health" in query.lower():
        base_response = "All team systems are operational. No critical issues detected."
    elif "task" in query.lower() or "todo" in query.lower():
        base_response = "I can help you manage tasks. Use /task-create to add a new task."
    elif "reminder" in query.lower():
        base_response = "I can set reminders for you. Use /set-reminder to schedule one."
    elif "meeting" in query.lower() or "summary" in query.lower():
        base_response = "I can summarize meetings. Use /summarize-meeting in a channel."
    else:
        base_response = "I've logged your request. Our productivity engine is analyzing the best way to assist you."

    # Apply Personality Tone
    if personality == "Casual":
        base_response = f"Hey! {base_response.replace('request', 'thing').replace('I\'ve', 'I\'ve').replace('Our', 'Our')}. Catch you in a bit! 🚀"
    elif personality == "Technical":
        base_response = f"[Bot Logs]: Trace ID {abs(hash(query)) % 10000} | Sentiment: {sentiment} | Score: {sentiment_data['score']:.2f} | Action: {base_response}"
    elif personality == "Friendly":
        base_response = f"Hi there! 😊 {base_response} Feel free to ask if you need anything else!"
    elif personality == "Formal":
        base_response = f"Dear colleague, {base_response} Please do not hesitate to contact me if you require further assistance."
    
    # Enhanced Translation Support
    if language == "Hindi":
        translation_map = {
            "I've detected this is urgent": "मैंने पहचाना है कि यह जरूरी है",
            "I understand this is concerning": "मैं समझता हूं कि यह चिंताजनक है",
            "All team systems are operational": "सभी टीम सिस्टम चालू हैं",
            "I've logged your request": "मैंने आपका अनुरोध दर्ज कर लिया है",
            "I can help you manage tasks": "मैं आपको कार्य प्रबंधन में मदद कर सकता हूं",
            "I can set reminders for you": "मैं आपके लिए अनुस्मारक सेट कर सकता हूं"
        }
        for eng, hin in translation_map.items():
            if eng in base_response:
                base_response = base_response.replace(eng, hin)
    
    return base_response

def generate_channel_report(channel_name: str) -> str:
    """
    Generates an advanced mock report for channel management.
    Enhanced with more detailed analytics.
    """
    return (
        f"📊 *Advanced Channel Analytics for #{channel_name}*\n"
        f"- Active Members: 12 (↑ 2 this week)\n"
        f"- Sentiment Index: 0.85 (Steady)\n"
        f"- Most Active Hour: 2:00 PM IST\n"
        f"- Message Volume: 342 messages this week\n"
        f"- Response Rate: 94%\n"
        f"- Top Contributors: @user1, @user2, @user3\n"
        f"- AI Suggestion: Channel health is good. Schedule a sync for pending tasks."
    )

def parse_reminder_time(time_str: str) -> Optional[datetime]:
    """
    Parse various time formats for reminders.
    Supports: "in 2 hours", "tomorrow 10am", "2024-12-31 14:00", etc.
    """
    time_str = time_str.lower().strip()
    now = datetime.now()
    
    # Relative time parsing
    if time_str.startswith("in "):
        try:
            parts = time_str.replace("in ", "").split()
            value = int(parts[0])
            unit = parts[1] if len(parts) > 1 else "minutes"
            
            if "minute" in unit:
                return now + timedelta(minutes=value)
            elif "hour" in unit:
                return now + timedelta(hours=value)
            elif "day" in unit:
                return now + timedelta(days=value)
            elif "week" in unit:
                return now + timedelta(weeks=value)
        except (ValueError, IndexError):
            pass
    
    # Tomorrow parsing
    if "tomorrow" in time_str:
        target_date = now + timedelta(days=1)
        # Try to extract time
        time_match = re.search(r'(\d{1,2})(?::(\d{2}))?\s*(am|pm)?', time_str)
        if time_match:
            hour = int(time_match.group(1))
            minute = int(time_match.group(2)) if time_match.group(2) else 0
            am_pm = time_match.group(3)
            if am_pm == "pm" and hour != 12:
                hour += 12
            elif am_pm == "am" and hour == 12:
                hour = 0
            target_date = target_date.replace(hour=hour, minute=minute, second=0, microsecond=0)
        return target_date
    
    # Try ISO format
    try:
        return datetime.fromisoformat(time_str)
    except (ValueError, AttributeError):
        pass
    
    # Default: 1 hour from now
    logger.warning(f"Could not parse time string: {time_str}, defaulting to 1 hour from now")
    return now + timedelta(hours=1)

def format_task_list(tasks: List[Dict]) -> str:
    """
    Format a list of tasks into a readable string.
    """
    if not tasks:
        return "No tasks found."
    
    formatted = "📋 *Your Tasks:*\n"
    for i, task in enumerate(tasks, 1):
        status_emoji = {
            "pending": "⏳",
            "in_progress": "🔄",
            "completed": "✅",
            "cancelled": "❌"
        }.get(task.get("status", "pending"), "📝")
        
        priority_emoji = {
            "low": "🟢",
            "medium": "🟡",
            "high": "🟠",
            "urgent": "🔴"
        }.get(task.get("priority", "medium"), "🟡")
        
        formatted += f"{i}. {status_emoji} {priority_emoji} *{task.get('title', 'Untitled')}*\n"
        if task.get("description"):
            formatted += f"   {task['description'][:100]}{'...' if len(task.get('description', '')) > 100 else ''}\n"
        if task.get("due_date"):
            formatted += f"   📅 Due: {task['due_date']}\n"
        formatted += "\n"
    
    return formatted

def generate_meeting_summary(messages: List[Dict]) -> str:
    """
    Generate a summary from a list of messages.
    Enhanced with better analysis.
    """
    if not messages:
        return "No messages to summarize."
    
    total_messages = len(messages)
    unique_users = len(set(msg.get("user", "unknown") for msg in messages))
    
    # Extract key topics (simple keyword extraction)
    all_text = " ".join(msg.get("text", "") for msg in messages).lower()
    topics = []
    topic_keywords = {
        "deployment": ["deploy", "release", "production"],
        "bugs": ["bug", "error", "issue", "fix"],
        "features": ["feature", "add", "implement", "new"],
        "meetings": ["meeting", "sync", "standup"],
        "deadlines": ["deadline", "due", "urgent", "asap"]
    }
    
    for topic, keywords in topic_keywords.items():
        if any(kw in all_text for kw in keywords):
            topics.append(topic)
    
    summary = f"📝 *Meeting Summary*\n"
    summary += f"- *Participants:* {unique_users} members\n"
    summary += f"- *Messages Analyzed:* {total_messages}\n"
    summary += f"- *Key Topics:* {', '.join(topics[:5]) if topics else 'General discussion'}\n\n"
    summary += "*Highlights:*\n"
    
    # Extract action items (messages with keywords like "will", "todo", "action")
    action_items = []
    for msg in messages[:20]:  # Check first 20 messages
        text = msg.get("text", "").lower()
        if any(word in text for word in ["will", "todo", "action", "need to", "should"]):
            action_items.append(msg.get("text", "")[:100])
    
    if action_items:
        summary += "\n*Action Items:*\n"
        for item in action_items[:5]:
            summary += f"- {item}\n"
    
    return summary

def validate_task_priority(priority: str) -> str:
    """
    Validate and normalize task priority.
    """
    priority = priority.lower().strip()
    valid_priorities = ["low", "medium", "high", "urgent"]
    if priority in valid_priorities:
        return priority
    return "medium"

def get_weather_emoji(condition: str) -> str:
    """
    Get emoji for weather condition.
    """
    condition_lower = condition.lower()
    if "sun" in condition_lower or "clear" in condition_lower:
        return "☀️"
    elif "rain" in condition_lower or "drizzle" in condition_lower:
        return "🌧️"
    elif "cloud" in condition_lower:
        return "☁️"
    elif "snow" in condition_lower:
        return "❄️"
    elif "storm" in condition_lower or "thunder" in condition_lower:
        return "⛈️"
    elif "fog" in condition_lower or "mist" in condition_lower:
        return "🌫️"
    else:
        return "🌤️"

def sanitize_text(text: str, max_length: int = 2000) -> str:
    """
    Sanitize and truncate text for Slack messages.
    """
    # Remove excessive whitespace
    text = re.sub(r'\s+', ' ', text)
    # Truncate if too long
    if len(text) > max_length:
        text = text[:max_length - 3] + "..."
    return text.strip()
314 lines•12.6 KB
python
🚀 Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ❤️

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