מודולים ראשיים

תיעוד מפורט של המודולים הראשיים בפרויקט.

File Management

class file_manager.BackupInfo(backup_id, user_id, created_at, file_count, total_size, backup_type, status, file_path, repo, path, metadata)[מקור]

Bases: object

מידע על גיבוי

פרמטרים:
__init__(backup_id, user_id, created_at, file_count, total_size, backup_type, status, file_path, repo, path, metadata)[מקור]
פרמטרים:
class file_manager.BackupManager[מקור]

Bases: object

מנהל גיבויים

__init__()[מקור]
save_backup_bytes(data, metadata)[מקור]

שומר ZIP של גיבוי בהתאם למצב האחסון ומחזיר backup_id או None במקרה כשל.

אם storage==mongo: שומר ל-GridFS עם המטאדטה. אם storage==fs: שומר לקובץ תחת backup_dir.

Return type:

Optional[str]

פרמטרים:
save_backup_file(file_path)[מקור]

שומר קובץ ZIP קיים לאחסון היעד (Mongo/FS) ומחזיר backup_id אם הצליח.

Return type:

Optional[str]

פרמטרים:

file_path (str)

list_backups(user_id)[מקור]

מחזירה רשימת קבצי ZIP ששייכים למשתמש המבקש בלבד.

כל פריט חייב להיות מסווג כשייך ל-user_id דרך אחד מהבאים: - metadata.json בתוך ה-ZIP עם שדה user_id תואם - דפוס מזהה בשם: backup_<user_id>_*

ZIPים ללא שיוך ברור למשתמש לא ייכללו כדי למנוע זליגת מידע.

Return type:

List[BackupInfo]

פרמטרים:

user_id (int)

restore_from_backup(user_id, backup_path, overwrite=True, purge=False, extra_tags=None)[מקור]

משחזר קבצים מ-ZIP למסד הנתונים. :rtype: Dict[str, Any]

  • purge=True: מסמן את כל הקבצים הקיימים של המשתמש כלא פעילים לפני השחזור

  • overwrite=True: שמירה תמיד כגרסה חדשה עבור אותו שם (כברירת מחדל)

החזרה: dict עם restored_files ו-errors

פרמטרים:
Return type:

Dict[str, Any]

delete_backups(user_id, backup_ids)[מקור]

מוחק מספר גיבויי ZIP לפי backup_id ממערכת הקבצים ומ-GridFS (אם בשימוש).

החזרה: {”deleted“: int, ”errors“: [str, …]}

Return type:

Dict[str, Any]

פרמטרים:
delete_backup(backup_id, user_id)[מקור]

מחיקת גיבוי

Return type:

bool

פרמטרים:
  • backup_id (str)

  • user_id (int)

GitHub Integration

github_menu_handler.safe_html_escape(text)[מקור]

Escape text for Telegram HTML; preserves / / and keeps existing HTML entities.

github_menu_handler.format_bytes(num)[מקור]

פורמט נחמד לגודל קובץ

Return type:

str

פרמטרים:

num (int)

class github_menu_handler.GitHubMenuHandler[מקור]

Bases: object

__init__()[מקור]
get_user_session(user_id)[מקור]

מחזיר או יוצר סשן משתמש בזיכרון

Return type:

Dict[str, Any]

פרמטרים:

user_id (int)

async show_browse_ref_menu(update, context)[מקור]

תפריט בחירת ref (ענף/תג) עם עימוד וטאבים.

Return type:

None

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_browse_search_results(update, context)[מקור]

חיפוש לפי שם קובץ (prefix/contains) עם עימוד ותוצאות לפתיחה.

Return type:

None

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async check_rate_limit(github_client, update_or_query)[מקור]

בודק את מגבלת ה-API של GitHub

Return type:

bool

פרמטרים:

github_client (github.Github)

async apply_rate_limit_delay(user_id)[מקור]

מוסיף השהייה בין בקשות API

פרמטרים:

user_id (int)

get_user_token(user_id)[מקור]

מקבל טוקן של משתמש - מהסשן או מהמסד נתונים

Return type:

Optional[str]

פרמטרים:

user_id (int)

async show_import_branch_menu(update, context)[מקור]

מציג בחירת ענף לייבוא ריפו (עימוד).

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async import_repo_from_zip(update, context, repo_full, branch)[מקור]

מוריד ZIP רשמי של GitHub (zipball) לענף, מחלץ ל-tmp, ומקליט קבצים ל-DB עם תגיות repo/source.

שמירה: CodeSnippet לקבצים טקסטואליים קטנים (עד IMPORT_MAX_FILE_BYTES) עד סך IMPORT_MAX_TOTAL_BYTES ומקס« IMPORT_MAX_FILES. מדלג על בינאריים, קבצי ענק, ותיקיות מיותרות. מנקה tmp בסוף.

פרמטרים:
async github_menu_command(update, context)[מקור]

מציג תפריט GitHub

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async handle_menu_callback(update, context)[מקור]

Handle menu button clicks

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_repo_selection(query, context)[מקור]

Show repository selection menu

פרמטרים:

context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_repos(update, context, page=0, query=None)[מקור]

מציג רשימת ריפוזיטוריז עם pagination

פרמטרים:
async show_upload_other_files(update, context)[מקור]

מציג רק קבצים שאינם מתויגים repo: ואינם קבצים גדולים, עם עימוד ואימוג’י לפי שפה.

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_upload_repos(update, context)[מקור]

מציג תפריט ריפואים לבחירת קבצים שמורים עם תגית repo: להעלאה

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_upload_repo_files(update, context, _repo_tag)[מקור]

מציג קבצים שמורים תחת תגית ריפו שנבחרה ומאפשר להעלותם עם עימוד

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • _repo_tag (str)

async upload_large_files_menu(update, context)[מקור]

מציג רשימת קבצים גדולים להעלאה לריפו הנבחר

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async handle_large_file_upload(update, context, file_id)[מקור]

מעלה קובץ גדול שנבחר לגיטהאב (עם אותן בדיקות כמו קובץ שמור רגיל)

פרמטרים:
async handle_saved_file_upload(update, context, file_id)[מקור]

מטפל בהעלאת קובץ שמור ל-GitHub

פרמטרים:
async handle_file_upload(update, context)[מקור]

Handle file upload

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async handle_text_input(update, context)[מקור]

Handle text input for various states

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_analyze_repo_menu(update, context)[מקור]

מציג תפריט לניתוח ריפו

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async request_repo_url(update, context)[מקור]

מבקש URL של ריפו לניתוח

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async analyze_another_repo(update, context)[מקור]

מציג תפריט בחירה לניתוח ריפו אחר

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async analyze_repository(update, context, repo_url)[מקור]

מנתח ריפוזיטורי ומציג תוצאות

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • repo_url (str)

async show_improvement_suggestions(update, context)[מקור]

מציג הצעות לשיפור

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_suggestion_details(update, context, suggestion_index)[מקור]

מציג פרטי הצעה ספציפית

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • suggestion_index (int)

async show_full_analysis(update, context)[מקור]

מציג ניתוח מלא

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async download_analysis_json(update, context)[מקור]

שולח קובץ JSON עם הניתוח המלא

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_analyze_results_menu(update, context)[מקור]

מציג מחדש את תפריט התוצאות

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async handle_repo_url_input(update, context)[מקור]

מטפל בקלט של URL לניתוח

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_delete_file_menu(update, context)[מקור]

מציג תפריט מחיקת קובץ מהריפו (דפדוף בכפתורים)

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_delete_repo_menu(update, context)[מקור]

מציג תפריט מחיקת ריפו שלם עם אזהרות

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async confirm_delete_file(update, context)[מקור]

מבצע מחיקת קובץ לאחר אישור

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async confirm_delete_repo_step1(update, context)[מקור]

מסך אישור סופי לפני מחיקת ריפו, מפנה ללחצן מחיקה סופי

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async confirm_delete_repo(update, context)[מקור]

מבצע מחיקת ריפו שלם לאחר אישור

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_danger_delete_menu(update, context)[מקור]

מציג תפריט מחיקות מסוכן

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_download_file_menu(update, context)[מקור]

מציג תפריט הורדת קובץ מהריפו (דפדוף בכפתורים)

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_repo_browser(update, context, only_keyboard=False)[מקור]

מציג דפדפן ריפו לפי נתיב ושימוש (view/download/delete), כולל breadcrumbs ועימוד.

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • only_keyboard (bool)

async handle_inline_query(update, context)[מקור]

Inline mode: חיפוש/ביצוע פעולות ישירות מכל צ’אט

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_notifications_menu(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async toggle_notifications(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async toggle_notifications_pr(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async toggle_notifications_issues(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async set_notifications_interval(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async notifications_check_now(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_pr_menu(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_create_pr_menu(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_confirm_create_pr(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async confirm_create_pr(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_merge_pr_menu(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_confirm_merge_pr(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async confirm_merge_pr(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async git_checkpoint(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_pre_upload_check(update, context)[מקור]

מציג בדיקות לפני העלאת קובץ שמור (הרשאות/קיום קובץ/ענף/תיקייה).

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async confirm_saved_upload(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async refresh_saved_checks(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_upload_branch_menu(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_upload_folder_menu(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async ask_upload_folder(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async create_checkpoint_doc(update, context, kind, name)[מקור]

יוצר קובץ הוראות שחזור לנקודת שמירה ושולח ל-flow של העלאה

פרמטרים:
async show_restore_checkpoint_menu(update, context)[מקור]

מציג רשימת תגיות נקודות שמירה לבחירה לשחזור

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_restore_tag_actions(update, context, tag_name)[מקור]

מציג פעולות אפשריות לשחזור מתגית נתונה

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • tag_name (str)

async create_branch_from_tag(update, context, tag_name)[מקור]

יוצר ענף חדש שמצביע ל-commit של התגית לשחזור נוח

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • tag_name (str)

async open_pr_from_branch(update, context, branch_name)[מקור]

פותח Pull Request מהענף שנוצר אל הענף הראשי של הריפו

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • branch_name (str)

async create_revert_pr_from_tag(update, context, tag_name)[מקור]

יוצר PR שמשחזר את מצב הריפו לתגית ע“י יצירת commit חדש עם עץ התגית על גבי base. כך תמיד יהיה diff וה-PR ייפתח בהצלחה.

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • tag_name (str)

async show_github_backup_menu(update, context)[מקור]

מציג תפריט גיבוי/שחזור עבור הריפו הנבחר

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async restore_zip_file_to_repo(update, context, zip_path, purge_first)[מקור]

שחזור קבצים מ-ZIP מקומי לריפו הנוכחי באמצעות Trees API (commit אחד)

Return type:

None

פרמטרים:
async github_upload_fix.github_upload_new_file(update, context)[מקור]

בקשה להעלאת קובץ חדש לגיטהאב

async github_upload_fix.handle_document_fixed(update, context)[מקור]

טיפול בקובץ שהתקבל

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async github_upload_fix.upload_to_github_fixed(update, context, status_message)[מקור]

העלאה מתוקנת לגיטהאב

async github_upload_fix.setup_minimal_commands(application)[מקור]

מחיקת כל הפקודות והשארת רק stats למנהל

Return type:

None

פרמטרים:

application (telegram.ext.Application)

async github_upload_fix.stats_command_secured(update, context)[מקור]

הצג סטטיסטיקות - רק לאמיר בירון

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async github_upload_fix.check_commands(update, context)[מקור]

בדיקת הפקודות הזמינות (רק לאמיר)

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

Backup System

class backup_menu_handler.BackupMenuHandler[מקור]

Bases: object

תפריט גיבוי ושחזור מלא + נקודות שמירה בגיט

__init__()[מקור]
async show_backup_menu(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async handle_callback_query(update, context)[מקור]
פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async send_rating_prompt(update, context, backup_id)[מקור]

שולח הודעת תיוג עם 3 כפתורים עבור גיבוי מסוים.

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • backup_id (str)

Code Processing

מנהל תצוגה מקדימה של קוד Code Preview Manager

class code_preview.CodePreviewManager[מקור]

Bases: object

מנהל תצוגה מקדימה של קוד

__init__()[מקור]
create_preview(code, file_name, programming_language)[מקור]

יוצר תצוגה מקדימה של קוד

Return type:

Dict[str, any]

פרמטרים:
  • code (str)

  • file_name (str)

  • programming_language (str)

format_preview_message(file_name, preview_info)[מקור]

יוצר הודעה מעוצבת לתצוגה מקדימה

Return type:

str

פרמטרים:
  • file_name (str)

  • preview_info (Dict)

create_quick_info(file_data)[מקור]

יוצר מידע מהיר על קובץ ללא תצוגת קוד

Return type:

str

פרמטרים:

file_data (Dict)

Search Engine

Repository Analysis

class repo_analyzer.RepoAnalyzer(github_token=None)[מקור]

Bases: object

מנתח ריפוזיטורי GitHub ומציע שיפורים

פרמטרים:

github_token (str | None)

MAX_FILE_SIZE = 102400
MAX_FILES = 50
LARGE_FILE_LINES = 500
LONG_FUNCTION_LINES = 50
CODE_EXTENSIONS = {'.c', '.cpp', '.cs', '.go', '.java', '.js', '.jsx', '.kt', '.m', '.php', '.py', '.r', '.rb', '.rs', '.scala', '.swift', '.ts', '.tsx'}
CONFIG_FILES = {'Cargo.toml', 'Gemfile', 'Package.swift', 'Pipfile', 'build.gradle', 'composer.json', 'go.mod', 'package.json', 'pom.xml', 'pyproject.toml', 'requirements.txt'}
IMPORTANT_FILES = {'.dockerignore', '.github/workflows', '.gitignore', '.gitlab-ci.yml', 'Dockerfile', 'LICENSE', 'LICENSE.md', 'LICENSE.txt', 'README', 'README.md', 'README.rst', 'README.txt', 'azure-pipelines.yml', 'docker-compose.yaml', 'docker-compose.yml'}
__init__(github_token=None)[מקור]

אתחול המנתח

פרמטרים:

github_token (str | None)

parse_github_url(url)[מקור]

מחלץ owner ו-repo מ-URL של GitHub

Return type:

tuple[str, str]

פרמטרים:

url (str)

async fetch_and_analyze_repo(repo_url)[מקור]

שולף ומנתח ריפוזיטורי מ-GitHub

Return type:

Dict[str, Any]

פרמטרים:

repo_url (str)

generate_improvement_suggestions(analysis_data)[מקור]

מייצר הצעות לשיפור על בסיס הניתוח

Return type:

List[Dict[str, Any]]

פרמטרים:

analysis_data (Dict[str, Any])

Batch Processing

מעבד Batch לעיבוד מרובה קבצים Batch Processor for Multiple Files

class batch_processor.BatchJob(job_id, user_id, operation, files, status='pending', progress=0, total=0, results=None, error_message='', start_time=0, end_time=0)[מקור]

Bases: object

עבודת batch

פרמטרים:
job_id: str
user_id: int
operation: str
files: List[str]
status: str = 'pending'
progress: int = 0
total: int = 0
results: Dict[str, Any] = None
error_message: str = ''
start_time: float = 0
end_time: float = 0
__init__(job_id, user_id, operation, files, status='pending', progress=0, total=0, results=None, error_message='', start_time=0, end_time=0)
פרמטרים:
Return type:

None

class batch_processor.BatchProcessor[מקור]

Bases: object

מעבד batch לפעולות על מרובה קבצים

__init__()[מקור]
create_job(user_id, operation, files)[מקור]

יצירת עבודת batch חדשה

Return type:

str

פרמטרים:
async process_files_batch(job_id, operation_func, **kwargs)[מקור]

עיבוד batch של קבצים

Return type:

BatchJob

פרמטרים:
async analyze_files_batch(user_id, file_names)[מקור]

ניתוח batch של קבצים

Return type:

str

פרמטרים:
async validate_files_batch(user_id, file_names)[מקור]

בדיקת תקינות batch של קבצים

Return type:

str

פרמטרים:
async export_files_batch(user_id, file_names, export_format='zip')[מקור]

ייצוא batch של קבצים

Return type:

str

פרמטרים:
get_job_status(job_id)[מקור]

קבלת סטטוס עבודת batch

Return type:

Optional[BatchJob]

פרמטרים:

job_id (str)

cleanup_old_jobs(max_age_hours=24)[מקור]

ניקוי עבודות ישנות

פרמטרים:

max_age_hours (int)

format_job_summary(job)[מקור]

פורמט סיכום עבודת batch

Return type:

str

פרמטרים:

job (BatchJob)

פקודות Batch לעיבוד מרובה קבצים Batch Commands for Multiple File Processing

async batch_commands.batch_analyze_command(update, context)[מקור]

פקודת ניתוח batch של קבצים

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async batch_commands.batch_validate_command(update, context)[מקור]

פקודת בדיקת תקינות batch

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async batch_commands.job_status_command(update, context)[מקור]

בדיקת סטטוס עבודת batch

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async batch_commands.large_file_command(update, context)[מקור]

פקודת הצגת קובץ גדול עם lazy loading

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async batch_commands.handle_batch_callbacks(update, context)[מקור]

טיפול בcallbacks של batch operations

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

batch_commands.setup_batch_handlers(application)[מקור]

הוספת handlers לפקודות batch

Large Files Handling

טיפול בקבצים גדולים עם ממשק כפתורים מתקדם Large Files Handler with Advanced Button Interface

class large_files_handler.LargeFilesHandler[מקור]

Bases: object

מנהל קבצים גדולים עם ממשק מתקדם

__init__()[מקור]
async show_large_files_menu(update, context, page=1)[מקור]

מציג תפריט קבצים גדולים עם ניווט בין עמודים

Return type:

None

פרמטרים:
async handle_file_selection(update, context)[מקור]

טיפול בבחירת קובץ גדול

Return type:

None

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async view_large_file(update, context)[מקור]

הצגת קובץ גדול - תצוגה מקדימה או שליחה כקובץ

Return type:

None

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async download_large_file(update, context)[מקור]

הורדת קובץ גדול

Return type:

None

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async delete_large_file_confirm(update, context)[מקור]

אישור מחיקת קובץ גדול

Return type:

None

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async delete_large_file(update, context)[מקור]

מחיקת קובץ גדול

Return type:

None

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async show_file_info(update, context)[מקור]

הצגת מידע מפורט על קובץ גדול

Return type:

None

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async edit_large_file(update, context)[מקור]

התחלת תהליך עריכת קובץ גדול

Return type:

int

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

Cache Management

מנהל Cache מתקדם עם Redis Advanced Cache Manager with Redis

class cache_manager.CacheManager[מקור]

Bases: object

מנהל Cache מתקדם עם Redis

__init__()[מקור]
connect()[מקור]

התחברות ל-Redis

get(key)[מקור]

קבלת ערך מה-cache

Return type:

Optional[Any]

פרמטרים:

key (str)

set(key, value, expire_seconds=300)[מקור]

שמירת ערך ב-cache

Return type:

bool

פרמטרים:
delete(key)[מקור]

מחיקת ערך מה-cache

Return type:

bool

פרמטרים:

key (str)

delete_pattern(pattern)[מקור]

מחיקת כל המפתחות שמתאימים לתבנית

Return type:

int

פרמטרים:

pattern (str)

invalidate_user_cache(user_id)[מקור]

מחיקת כל ה-cache של משתמש ספציפי

פרמטרים:

user_id (int)

get_stats()[מקור]

סטטיסטיקות cache

Return type:

Dict[str, Any]

cache_manager.cached(expire_seconds=300, key_prefix='default')[מקור]

דקורטור לcaching פונקציות

פרמטרים:
  • expire_seconds (int)

  • key_prefix (str)

cache_manager.async_cached(expire_seconds=300, key_prefix='default')[מקור]

דקורטור לcaching פונקציות async

פרמטרים:
  • expire_seconds (int)

  • key_prefix (str)

פקודות ניהול Cache לבוט Cache Management Commands for Bot

async cache_commands.cache_stats_command(update, context)[מקור]

הצגת סטטיסטיקות cache

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async cache_commands.clear_cache_command(update, context)[מקור]

ניקוי cache של המשתמש

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

cache_commands.setup_cache_handlers(application)[מקור]

הוספת handlers לפקודות cache

User Statistics

class user_stats.UserStats[מקור]

Bases: object

__init__()[מקור]
log_user(user_id, username=None)[מקור]

רישום משתמש ב-MongoDB

get_weekly_stats()[מקור]

סטטיסטיקת שבוע אחרון מ-MongoDB

get_all_time_stats()[מקור]

סטטיסטיקות כלליות מ-MongoDB

Activity Reporting

קובץ פשוט לדיווח פעילות - העתק את הקובץ הזה לכל בוט

class activity_reporter.SimpleActivityReporter(mongodb_uri, service_id, service_name=None)[מקור]

Bases: object

__init__(mongodb_uri, service_id, service_name=None)[מקור]

mongodb_uri: חיבור למונגו (אותו מהבוט המרכזי) service_id: מזהה השירות ב-Render service_name: שם הבוט (אופציונלי)

report_activity(user_id)[מקור]

דיווח פעילות פשוט

activity_reporter.create_reporter(mongodb_uri, service_id, service_name=None)[מקור]

יצירת reporter פשוט

Utilities

פונקציות עזר כלליות לבוט שומר קבצי קוד General Utility Functions for Code Keeper Bot

class utils.CodeErrorLogger[מקור]

Bases: object

מערכת לוגים ייעודית לשגיאות עיבוד קוד

__init__()[מקור]
log_code_processing_error(user_id, error_type, error_message, context=None)[מקור]

רישום שגיאות עיבוד קוד

פרמטרים:
log_code_activity(user_id, activity_type, details=None)[מקור]

רישום פעילות עיבוד קוד

פרמטרים:
log_validation_failure(user_id, code_length, error_reason)[מקור]

רישום כשל באימות קוד

פרמטרים:
  • user_id (int)

  • code_length (int)

  • error_reason (str)

log_sanitization_success(user_id, original_length, cleaned_length)[מקור]

רישום הצלחה בסניטציה

פרמטרים:
  • user_id (int)

  • original_length (int)

  • cleaned_length (int)

class utils.TimeUtils[מקור]

Bases: object

כלים לעבודה עם זמן ותאריכים

static format_relative_time(dt)[מקור]

פורמט זמן יחסי (לפני 5 דקות, אתמול וכו«)

Return type:

str

פרמטרים:

dt (datetime)

static parse_date_string(date_str)[מקור]

פרסור מחרוזת תאריך לאובייקט datetime

Return type:

Optional[datetime]

פרמטרים:

date_str (str)

static get_time_ranges(period)[מקור]

קבלת טווח זמנים לפי תקופה

Return type:

Tuple[datetime, datetime]

פרמטרים:

period (str)

class utils.TextUtils[מקור]

Bases: object

כלים לעבודה עם טקסט

static truncate_text(text, max_length=100, suffix='...')[מקור]

קיצור טקסט עם סיומת

Return type:

str

פרמטרים:
static escape_markdown(text, version=2)[מקור]

הגנה על תווים מיוחדים ב-Markdown

Return type:

str

פרמטרים:
static clean_filename(filename)[מקור]

ניקוי שם קובץ מתווים לא חוקיים

Return type:

str

פרמטרים:

filename (str)

static extract_hashtags(text)[מקור]

חילוץ תגיות מטקסט

Return type:

List[str]

פרמטרים:

text (str)

static highlight_text(text, query, tag='**')[מקור]

הדגשת מילות חיפוש בטקסט

Return type:

str

פרמטרים:
static format_file_size(size_bytes)[מקור]

פורמט גודל קובץ (bytes -> KB/MB/GB)

Return type:

str

פרמטרים:

size_bytes (int)

static pluralize_hebrew(count, singular, plural)[מקור]

צורת רבים עבריות

Return type:

str

פרמטרים:
class utils.SecurityUtils[מקור]

Bases: object

כלים אמינות ובטיחות

static generate_secure_token(length=32)[מקור]

יצירת טוקן מאובטח

Return type:

str

פרמטרים:

length (int)

static hash_content(content, algorithm='sha256')[מקור]

יצירת hash לתוכן

Return type:

str

פרמטרים:
  • content (str)

  • algorithm (str)

static validate_user_input(text, max_length=10000, forbidden_patterns=None)[מקור]

בדיקת קלט משתמש

Return type:

bool

פרמטרים:
static sanitize_code(code)[מקור]

ניקוי קוד מתוכן מסוכן (בסיסי)

Return type:

str

פרמטרים:

code (str)

class utils.TelegramUtils[מקור]

Bases: object

כלים לעבודה עם Telegram

async static send_typing_action(update, context)[מקור]

שליחת אקשן »כותב…«

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async static send_document_action(update, context)[מקור]

שליחת אקשן »שולח מסמך…«

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

static get_user_mention(user)[מקור]

קבלת מנשן למשתמש

Return type:

str

פרמטרים:

user (telegram.User)

static split_long_message(text, max_length=4096)[מקור]

חלוקת הודעה ארוכה לחלקים

Return type:

List[str]

פרמטרים:
async static safe_edit_message_text(query, text, reply_markup=None, parse_mode=None)[מקור]

עריכת טקסט הודעה בבטיחות: מתעלם משגיאת »Message is not modified«.

Return type:

None

פרמטרים:
  • text (str)

  • parse_mode (str | None)

async static safe_edit_message_reply_markup(query, reply_markup=None)[מקור]

עריכת מקלדת הודעה בבטיחות: מתעלם משגיאת »Message is not modified«.

Return type:

None

class utils.CallbackQueryGuard[מקור]

Bases: object

Guard גורף ללחיצות כפולות על כפתורי CallbackQuery.

מבוסס על טביעת אצבע של המשתמש/הודעה/הנתון (callback_data) כדי לחסום את אותה פעולה בחלון זמן קצר, בלי לחסום פעולות שונות.

DEFAULT_WINDOW_SECONDS: float = 1.2
static should_block(update, context, window_seconds=None)[מקור]

בודק האם יש לחסום את העדכון כלחיצה כפולה.

אם זו אותה טביעת אצבע בתוך חלון הזמן – נחסום; אחרת נסמן ונאפשר.

Return type:

bool

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • window_seconds (float | None)

async static should_block_async(update, context, window_seconds=None)[מקור]

בודק בצורה אטומית (עם נעילה) אם לחסום לחיצה כפולה של אותו משתמש.

חסימה מבוססת חלון זמן פר-משתמש, ללא תלות ב-message_id/data, כדי למנוע מרוץ.

Return type:

bool

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

  • window_seconds (float | None)

class utils.AsyncUtils[מקור]

Bases: object

כלים לעבודה אסינכרונית

async static run_with_timeout(coro, timeout=30.0)[מקור]

הרצת פונקציה אסינכרונית עם timeout

פרמטרים:

timeout (float)

async static batch_process(items, process_func, batch_size=10, delay=0.1)[מקור]

עיבוד פריטים בקבוצות

Return type:

List[Any]

פרמטרים:
class utils.PerformanceUtils[מקור]

Bases: object

כלים למדידת ביצועים

static timing_decorator(func)[מקור]

דקורטור למדידת זמן ביצוע

static measure_time(operation_name)[מקור]

מדידת זמן עם context manager

פרמטרים:

operation_name (str)

class utils.ValidationUtils[מקור]

Bases: object

כלים לוולידציה

static is_valid_filename(filename)[מקור]

בדיקת תקינות שם קובץ

Return type:

bool

פרמטרים:

filename (str)

static is_safe_code(code, programming_language)[מקור]

בדיקה בסיסית של בטיחות קוד

Return type:

Tuple[bool, List[str]]

פרמטרים:
  • code (str)

  • programming_language (str)

class utils.FileUtils[מקור]

Bases: object

כלים לעבודה עם קבצים

async static download_file(url, max_size=10485760)[מקור]

הורדת קובץ מ-URL

Return type:

Optional[bytes]

פרמטרים:
static get_file_extension(filename)[מקור]

קבלת סיומת קובץ

Return type:

str

פרמטרים:

filename (str)

static get_mime_type(filename)[מקור]

קבלת MIME type של קובץ

Return type:

str

פרמטרים:

filename (str)

async static create_temp_file(content, suffix='')[מקור]

יצירת קובץ זמני

Return type:

str

פרמטרים:
class utils.ConfigUtils[מקור]

Bases: object

כלים לקונפיגורציה

static load_json_config(file_path, default=None)[מקור]

טעינת קונפיגורציה מקובץ JSON

Return type:

Dict

פרמטרים:
static save_json_config(file_path, config)[מקור]

שמירת קונפיגורציה לקובץ JSON

Return type:

bool

פרמטרים:
class utils.CacheUtils[מקור]

Bases: object

כלים לקאש זמני

classmethod set(key, value, ttl=300)[מקור]

שמירה בקאש עם TTL (שניות)

פרמטרים:
classmethod get(key, default=None)[מקור]

קבלה מהקאש

Return type:

Any

פרמטרים:
classmethod delete(key)[מקור]

מחיקה מהקאש

פרמטרים:

key (str)

classmethod clear()[מקור]

ניקוי כל הקאש

utils.get_memory_usage()[מקור]

קבלת נתוני זיכרון

Return type:

Dict[str, float]

utils.setup_logging(level='INFO', log_file=None)[מקור]

הגדרת לוגים

Return type:

Logger

פרמטרים:
utils.generate_summary_stats(files_data)[מקור]

יצירת סיכום סטטיסטיקות

Return type:

Dict[str, Any]

פרמטרים:

files_data (List[Dict])

utils.detect_language_from_filename(filename)[מקור]

זיהוי שפת תכנות לפי סיומת הקובץ

Return type:

str

פרמטרים:

filename (str)

utils.get_language_emoji(language)[מקור]

מחזיר אימוג’י מתאים לשפת התכנות

Return type:

str

פרמטרים:

language (str)

class utils.SensitiveDataFilter(name='')[מקור]

Bases: Filter

מסנן שמטשטש טוקנים ונתונים רגישים בלוגים.

filter(record)[מקור]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

Return type:

bool

פרמטרים:

record (LogRecord)

utils.install_sensitive_filter()[מקור]

התקנת המסנן על כל ה-handlers הקיימים.

Lazy Loading

מנהל Lazy Loading לקבצים גדולים Lazy Loading Manager for Large Files

class lazy_loader.FileChunk(file_name, chunk_index, start_line, end_line, content, total_chunks, total_lines)[מקור]

Bases: object

חלק מקובץ גדול

פרמטרים:
  • file_name (str)

  • chunk_index (int)

  • start_line (int)

  • end_line (int)

  • content (str)

  • total_chunks (int)

  • total_lines (int)

file_name: str
chunk_index: int
start_line: int
end_line: int
content: str
total_chunks: int
total_lines: int
__init__(file_name, chunk_index, start_line, end_line, content, total_chunks, total_lines)
פרמטרים:
  • file_name (str)

  • chunk_index (int)

  • start_line (int)

  • end_line (int)

  • content (str)

  • total_chunks (int)

  • total_lines (int)

Return type:

None

class lazy_loader.LazyLoader[מקור]

Bases: object

מנהל Lazy Loading לקבצים גדולים

__init__()[מקור]
is_large_file(code)[מקור]

בדיקה אם קובץ נחשב גדול

Return type:

bool

פרמטרים:

code (str)

create_chunks(code, file_name)[מקור]

חלוקת קובץ גדול לchunks

Return type:

List[FileChunk]

פרמטרים:
get_file_chunk(user_id, file_name, chunk_index)[מקור]

קבלת chunk ספציפי מקובץ

Return type:

Optional[FileChunk]

פרמטרים:
  • user_id (int)

  • file_name (str)

  • chunk_index (int)

get_file_summary(code, file_name, programming_language)[מקור]

יוצר סיכום של קובץ גדול

Return type:

Dict[str, any]

פרמטרים:
  • code (str)

  • file_name (str)

  • programming_language (str)

format_chunk_message(chunk, programming_language)[מקור]

פורמט הודעה לchunk

Return type:

str

פרמטרים:
get_navigation_keyboard(chunk, user_id)[מקור]

יוצר מקלדת ניווט לchunks

פרמטרים:
async show_large_file_lazy(update, user_id, file_name, chunk_index=0)[מקור]

הצגת קובץ גדול עם lazy loading

פרמטרים:
  • user_id (int)

  • file_name (str)

  • chunk_index (int)

Integrations

Terminal Commands

Terminal commands: sandboxed command execution via Docker containers.

async terminal_commands.run_in_sandbox(command, timeout_sec=10, max_output_chars=3500)[מקור]

Run a shell command inside a locked-down Docker container and return (rc, output).

Return type:

Tuple[int, str]

פרמטרים:
  • command (str)

  • timeout_sec (int)

  • max_output_chars (int)

async terminal_commands.terminal_enter(update, context)[מקור]

Enter terminal mode if Docker is available.

Return type:

int

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async terminal_commands.terminal_exit(update, context)[מקור]

Exit terminal mode.

Return type:

int

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async terminal_commands.terminal_run_command(update, context)[מקור]

Run a command string inside the sandbox and send the output.

Return type:

int

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

async terminal_commands.terminal_command(update, context)[מקור]

/terminal command to enter terminal mode.

Return type:

int

פרמטרים:
  • update (telegram.Update)

  • context (telegram.ext.ContextTypes.DEFAULT_TYPE)

terminal_commands.setup_terminal_handlers(application)[מקור]

Register terminal conversation handlers and commands (disabled on Render).

פרמטרים:

application (telegram.ext.Application)

Autocomplete Manager

מנהל אוטו-השלמה לשמות קבצים ותגיות Autocomplete Manager for File Names and Tags

class autocomplete_manager.AutocompleteManager[מקור]

Bases: object

מנהל אוטו-השלמה חכם

__init__()[מקור]
get_user_filenames(user_id)[מקור]

קבלת כל שמות הקבצים של משתמש לאוטו-השלמה

Return type:

List[str]

פרמטרים:

user_id (int)

get_user_tags(user_id)[מקור]

קבלת כל התגיות של משתמש לאוטו-השלמה

Return type:

List[str]

פרמטרים:

user_id (int)

suggest_filenames(user_id, partial_name, limit=5)[מקור]

הצעות שמות קבצים בהתבסס על קלט חלקי

Return type:

List[Dict[str, any]]

פרמטרים:
  • user_id (int)

  • partial_name (str)

  • limit (int)

suggest_tags(user_id, partial_tag, limit=5)[מקור]

הצעות תגיות בהתבסס על קלט חלקי

Return type:

List[Dict[str, any]]

פרמטרים:
  • user_id (int)

  • partial_tag (str)

  • limit (int)

get_smart_suggestions(user_id, input_text, suggestion_type='auto')[מקור]

הצעות חכמות בהתבסס על הקשר

Return type:

List[str]

פרמטרים:
  • user_id (int)

  • input_text (str)

  • suggestion_type (str)

get_recent_files(user_id, limit=5)[מקור]

קבלת שמות הקבצים שנערכו לאחרונה

Return type:

List[str]

פרמטרים:
invalidate_cache(user_id)[מקור]

ביטול cache של אוטו-השלמה למשתמש

פרמטרים:

user_id (int)