File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/engines/__pycache__/ircbot.cpython-310.pyc
Back
o ;j�( � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlZ ddl Z ddlZ e�e �Zedd�Zedd�ZG dd � d �Z ddd�ZdS )a IRC Bot engine .. versionadded:: 2017.7.0 Example Configuration .. code-block:: yaml engines: - ircbot: nick: <nick> username: <username> password: <password> host: irc.oftc.net port: 7000 channels: - salt-test - '##something' use_ssl: True use_sasl: True disable_query: True allow_hosts: - salt/engineer/.* allow_nicks: - gtmanfred Available commands on irc are: ping return pong echo <stuff> return <stuff> targeted at the user who sent the commands event <tag> [<extra>, <data>] fire event on the master or minion event stream with the tag `salt/engines/ircbot/<tag>` and a data object with a list of everything else sent in the message Example of usage .. code-block:: text 08:33:57 @gtmanfred > !ping 08:33:57 gtmanbot > gtmanfred: pong 08:34:02 @gtmanfred > !echo ping 08:34:02 gtmanbot > ping 08:34:17 @gtmanfred > !event test/tag/ircbot irc is useful 08:34:17 gtmanbot > gtmanfred: TaDa! .. code-block:: text [DEBUG ] Sending event: tag = salt/engines/ircbot/test/tag/ircbot; data = {'_stamp': '2016-11-28T14:34:16.633623', 'data': ['irc', 'is', 'useful']} � N)� namedtuple�Eventzsource code line� PrivEventz/source nick user host code channel command linec @ s� e Zd Z d$dd�Zdd � Zd d� Zedd � �Zdd� Zdd� Z dd� Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zd d!� Zd"d#� ZdS )%� IRCClient� NF�!Tc C sz || _ || _|| _|p|| _|| _|pg | _|| _|| _| | _| | _ || _ || _tj jjjdd�| _| j�� | �� d S )NF)�make_current)�nick�host�port�username�password�channels�ssl�sasl�char�allow_hosts�allow_nicks� disable_query�salt�ext�tornado�ioloop�IOLoop�io_loopr �_connect) �selfr r r r r r �use_ssl�use_saslr r r r � r �G/opt/saltstack/salt/lib/python3.10/site-packages/salt/engines/ircbot.py�__init__M s zIRCClient.__init__c C sv t � t jt jd�}| jdu rtjjjj|dtj id�| _ n tjjj�|�| _ | j �| j � | j �| j| jf| j� d S )Nr T� cert_reqs)Zssl_options)�socket�AF_INET�SOCK_STREAMr r r r ZiostreamZSSLIOStream� CERT_NONE�_streamZIOStreamZset_close_callback� on_closed�connectr r � on_connect)r �_sockr r r r l s �zIRCClient._connectc C s | j �d| j� d S )Nz )r'