<commit_before>package main

import (
	"fmt"
	"github.com/cixtor/slackapi"
)

// MonitorRealTimeMessages prints all the supported websocket events.
func MonitorRealTimeMessages(client *slackapi.SlackAPI) {
	rtm, err := client.NewRTM()

	if err != nil {
		fmt.Println("RTM error;", err)
		return
	}

	go rtm.ManageEvents()

	for msg := range rtm.Events {
		switch event := msg.Data.(type) {
		case *slackapi.HelloEvent:
			fmt.Println("hello; connection established")

		case *slackapi.PresenceChangeEvent:
			fmt.Println("presence;", event.User, "=>", event.Presence)

		case *slackapi.MessageEvent:
			fmt.Printf("message; %s@%s: %#v\n", event.User, event.Channel, event.Text)

		case *slackapi.ErrorEvent:
			fmt.Println("error;", event.Text)

		case *slackapi.ReconnectURLEvent:
			fmt.Println("reconnect;", event.URL)

		default:
			fmt.Printf("%s; %#v\n", msg.Type, msg.Data)
		}
	}
}<commit_msg>Add example of how to stop the RTM connection programmatically<commit_after>package main

import (
	"fmt"
	"github.com/cixtor/slackapi"
)

// MonitorRealTimeMessages prints all the supported websocket events.
func MonitorRealTimeMessages(client *slackapi.SlackAPI) {
	rtm, err := client.NewRTM()

	if err != nil {
		fmt.Println("RTM error;", err)
		return
	}

	go rtm.ManageEvents()

	for msg := range rtm.Events {
		switch event := msg.Data.(type) {
		case *slackapi.HelloEvent:
			fmt.Println("hello; connection established")

		case *slackapi.PresenceChangeEvent:
			fmt.Println("presence;", event.User, "=>", event.Presence)

		case *slackapi.MessageEvent:
			if event.Text == "stop" {
				rtm.Stop()
			} else {
				fmt.Printf(
					"message; %s@%s: %#v\n",
					event.User,
					event.Channel,
					event.Text)
			}

		case *slackapi.ErrorEvent:
			fmt.Println("error;", event.Text)

		case *slackapi.ReconnectURLEvent:
			fmt.Println("reconnect;", event.URL)

		default:
			fmt.Printf("%s; %#v\n", msg.Type, msg.Data)
		}
	}

	fmt.Println("stopped")
}
{'fraction_non_alphanumeric': 0.15160796324655437, 'fraction_numerical': 0.0, 'mean_word_length': 3.8635235732009927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5858634', 'n_tokens_mistral': 809, 'n_tokens_neox': 723, 'n_words': 146}