# 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")