Start a RTM connection. Fetch the web socket url to connect to, current user details
and list of channel ids where the current user has had conversation.

@param slackToken slack token which you get from slack for the integration you create
764465
public void connectRTM(String slackToken) {
        RTM rtm = restTemplate.getForEntity(slackApiEndpoints.getRtmConnectApi(), RTM.class, slackToken).getBody();
        currentUser = rtm.getSelf();
        webSocketUrl = rtm.getUrl();
        getImChannels(slackToken, 200,"");
    }
495019
public void connect(IConnection conn) {
        if (conn instanceof RTMPConnection) {
            if (!isConnected()) {
                source = conn;
                SharedObjectMessage msg = new SharedObjectMessage(name, 0, isPersistent());
                msg.addEvent(new SharedObjectEvent(Type.SERVER_CONNECT, null, null));
                Channel c = ((RTMPConnection) conn).getChannel(3);
                c.write(msg);
            } else {
                throw new UnsupportedOperationException("Already connected");
            }
        } else {
            throw new UnsupportedOperationException("Only RTMP connections are supported");
        }
    }
1014027
public function send()
    {
        $incomingUrl      = !empty($this->incomingUrl) ? $this->incomingUrl : $this->sdkConfig[self::SLACK_MESSENGER_CONFIG_KEY]['incoming_url'];
        $clientAttributes = is_array($this->clientAttributes) ? $this->clientAttributes : array();
        $client           = new Client($incomingUrl, $clientAttributes);
        $message          = new Message($client);
        $message->to($this->targetChannel);
        if (!empty($this->attachMessage)) {
            $message->attach($this->attachMessage);
        }
        if (!empty($this->contentMessage)) {
            $message->setText($this->contentMessage);
        }
        $message->send();
    }
833847
def mark(self, group_name, ts):
        
        group_id = self.get_group_id(group_name)
        self.params.update({
            'channel': group_id,
            'ts':      ts,
            })
        return FromUrl('https://slack.com/api/groups.mark', self._requests)(data=self.params).post()
855075
def _create_slack_with_token(token: Token) -> SlackClient:
    
    if token != Token(''):
        return SlackClient(token=token)
    raise MissingToken("The empty string is an invalid Slack API token")
1110530
def __connect(self, wsURL, symbol):
        ''''''
        self.logger.debug("Starting thread")

        self.ws = websocket.WebSocketApp(wsURL,
                                         on_message=self.__on_message,
                                         on_close=self.__on_close,
                                         on_open=self.__on_open,
                                         on_error=self.__on_error,
                                         # We can login using email/pass or API key
                                         header=self.__get_auth())

        self.wst = threading.Thread(target=lambda: self.ws.run_forever())
        self.wst.daemon = True
        self.wst.start()
        self.logger.debug("Started thread")

        # Wait for connect before continuing
        conn_timeout = 5
        while not self.ws.sock or not self.ws.sock.connected and conn_timeout:
            sleep(1)
            conn_timeout -= 1
        if not conn_timeout:
            self.logger.error("Couldn't connect to WS! Exiting.")
            self.exit()
            sys.exit(1)
859937
@Override
    public synchronized void startChain(ChainData chain) throws ChannelException, ChainException {
        String chainName = (null != chain) ? chain.getName() : null;
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "startChain: " + chainName);
        }
        if (null == chain) {
            throw new InvalidChainNameException("Null chain");
        }

        // Ensure we have an inbound chain.
        if (FlowType.OUTBOUND.equals(chain.getType())) {
            throw new InvalidChainNameException("Outbound chain cannot use this interface.");
        }

        startChainInternal(chain);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "startChain");
        }
    }
1145806
def slack_message():
    """"""
    # Incoming request format:
    # token=TOKEN
    # team_id=T0001
    # team_domain=example
    # channel_id=C12345
    # channel_name=test
    # user_id=U12345
    # user_name=Steve
    # command=/weather
    # text=94070

    # Verify Slack token lines up
    if request.form['token'] != SLACK_TOKEN:
        return ('Provided Slack token from message didn\'t match our server\'s Slack token. '
                'Please double check they are aligned', 403)

    # Extract our text and make a card
    text = request.form['text']
    user_name = request.form['user_name']
    # Pre-emptively extract channel name before taking actions (transaction-esque)
    channel_name = request.form['channel_name']
    card = make_trello_card(name='{text} ({user_name})'.format(text=text, user_name=user_name))

    # Send a message to Slack about our success
    # TODO: Escape our content
    send_slack_message(channel='#{channel_name}'.format(channel_name=channel_name),
                       text='Trello card "<{url}|{text}>" created by "{user_name}"'
                       .format(url=card.url, text=text, user_name=user_name))

    # Reply with nothing (as the external message does more)
    return ''
486337
def invite(self, group_name, user):
        
        group_id = self.get_group_id(group_name)
        self.params.update({
            'channel': group_id,
            'user':    user,
            })
        return FromUrl('https://slack.com/api/groups.invite', self._requests)(data=self.params)
474881
def im_open(self, *, user: str, **kwargs) -> SlackResponse:
        
        kwargs.update({"user": user})
        return self.api_call("im.open", json=kwargs)
1044222
public void connect() throws Exception {
        logger.debug("[connect] initializing new connection");

        if (timer != null) {
            timer.cancel();
        }

        if (isConnected()) {
            return;
        }

        synchronized (webSocketHandler.getNotifyConnectionObject()) {
            webSocketConnectionManager.start();

            try {
                webSocketHandler.getNotifyConnectionObject().wait(TimeUnit.SECONDS.toMillis(WEBSOCKET_TIMEOUT));
            }
            catch (InterruptedException e) {
                onConnectionClosed();
                logger.debug("[connect] not open");
                throw new Exception("websocket connection not open");
            }

            if (!isConnected()) {
                onConnectionClosed();
                logger.debug("[connect] timeout");
                throw new Exception("websocket connection timeout");
            }
        }
    }
182993
def get_slack_channels(self, token):
        '''
        
        '''

        ret = salt.utils.slack.query(
            function='rooms',
            api_key=token,
            # These won't be honored until https://github.com/saltstack/salt/pull/41187/files is merged
            opts={
                'exclude_archived': True,
                'exclude_members': True
            })
        channels = {}
        if 'message' in ret:
            for item in ret['message']:
                channels[item['id']] = item['name']
        return channels
635595
def slack_user(request, api_data):
    
    if request.user.is_anonymous:
        return request, api_data

    data = deepcopy(api_data)

    slacker, _ = SlackUser.objects.get_or_create(slacker=request.user)
    slacker.access_token = data.pop('access_token')
    slacker.extras = data
    slacker.save()

    messages.add_message(request, messages.SUCCESS, 'Your account has been successfully updated with '
                                                    'Slack. You can share your messages within your slack '
                                                    'domain.')

    return request, api_data
1049576
def chat_getPermalink(
        self, *, channel: str, message_ts: str, **kwargs
    ) -> SlackResponse:
        
        kwargs.update({"channel": channel, "message_ts": message_ts})
        return self.api_call("chat.getPermalink", http_verb="GET", params=kwargs)
1315512
def mark(self, channel, ts):
        
        self.params.update({
            'channel': channel,
            'ts':      ts,
            })
        return FromUrl('https://slack.com/api/im.mark', self._requests)(data=self.params).post()
238225
private HttpURLConnection getConnection(String uri, String postJson, String token) throws IOException {
		int tries = 0;
		IOException last = null;

		while (tries++ <= retries) {
			try {
				return getConnectionOnce(uri, postJson, token);
			} catch (IOException ex) {
				last = ex;
			}
		}

		throw last;
	}
130458
def stop(self):
        """"""
        self._logger.debug("The Slack RTMClient is shutting down.")
        self._stopped = True
        self._close_websocket()