This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

php pastebin - collaborative irc debugging view php source

Paste #82

Posted by: np for hexchat
Posted on: 2026-01-11 23:57:11
Age: 21 days ago
Views: 18
# HexChat Python Plugin: Now Playing as Action (/me)
# Сохрани как nowplaying_action.py в ~/.config/hexchat/addons/
# Загрузи: /py load nowplaying_action.py
# Использование: /np — отправит в чат действие вроде "* ТвойНик сейчас слушает Artist - Title"

__module_name__ = "Now Playing Action"
__module_version__ = "1.1"
__module_description__ = "Sends current music info as /me action using playerctl"

import hexchat
import subprocess

def get_now_playing():
    try:
        # Формат: Artist - Title (Player: player_name)
        output = subprocess.check_output([
            'playerctl', 'metadata', '--format',
            '{{artist}} - {{title}} ({{playerName}})'
        ]).decode('utf-8').strip()
        
        # Если ничего не играет или пустые поля
        if not output or output.startswith(' - ') or output == '( )':
            return "ничего не играет"
        
        return output
    
    except subprocess.CalledProcessError:
        return "ни один плеер не найден"
    except FileNotFoundError:
        return "playerctl не установлен"
    except Exception:
        return "ошибка получения трека"

def now_playing_action_cb(word, word_eol, userdata):
    info = get_now_playing()
    
    # Отправляем как действие (/me)
    hexchat.command(f"me сейчас слушает {info}")
    
    # Опционально: выводим в консоль HexChat для себя
    hexchat.prnt(f"* Ты сейчас слушаешь {info}")
    
    return hexchat.EAT_ALL

# Регистрируем команду /np
hexchat.hook_command("np", now_playing_action_cb, 
                     help="/np — отправить в чат действие с текущим треком")

print(f"{__module_name__} v{__module_version__} загружен. Используй /np")

Download raw | Create new paste

© BitByByte, 2025.