{"id":19251896,"url":"https://github.com/thrawn01/channel-stats","last_synced_at":"2025-04-21T13:30:40.846Z","repository":{"id":57592699,"uuid":"124815730","full_name":"thrawn01/channel-stats","owner":"thrawn01","description":"A slack bot to collect sentiment analysis and other statistics for a channel","archived":false,"fork":false,"pushed_at":"2019-01-15T21:21:11.000Z","size":5667,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T13:37:54.937Z","etag":null,"topics":["channel-stats","golang","sentiment-analysis","slack","stats"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thrawn01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-12T01:12:51.000Z","updated_at":"2023-08-15T00:03:23.000Z","dependencies_parsed_at":"2022-09-13T09:12:23.013Z","dependency_job_id":null,"html_url":"https://github.com/thrawn01/channel-stats","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thrawn01%2Fchannel-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thrawn01%2Fchannel-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thrawn01%2Fchannel-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thrawn01%2Fchannel-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thrawn01","download_url":"https://codeload.github.com/thrawn01/channel-stats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250064509,"owners_count":21368917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["channel-stats","golang","sentiment-analysis","slack","stats"],"created_at":"2024-11-09T18:24:29.792Z","updated_at":"2025-04-21T13:30:38.934Z","avatar_url":"https://github.com/thrawn01.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Channel Stats Slack Bot\nA slack bot to collect sentiment analysis and other statistics for a channel.\n\n## Web Interface\nChannel-stats provides a simple Web UI that displays graphs for the last 7 days and by default it displays\nthe first channel it discovers. You can change the channel and time range by passing the `start-hour`, `end-hour`\n and `channel` form parameters identical to that of the API. See the API docs below for valid parameters and format.\n\nUI is available via http://localhost:2020/ui/index\n\n![Screenshot Here](https://raw.githubusercontent.com/thrawn01/channel-stats/master/ui-screenshot.png)\n\n###### Help wanted \nThe UI needs some love, the original plan was to add a black header with a channel dropdown and date selectors but \nmy UI foo sucks. Send a PR if you have some ideas and want to improve it! (We don't have to use the png graphs, we\ncould also use something like chartjs to make the graphs pretty.) If you run `go run ./cmd/channel-stats/main.go` \nit will serve the files in `./html` instead of the compiled binary files. So you can change anything about the UI and \nsee the result without needing to recompile.\n\n## Run via docker\nEasiest way to get started is by running `channel-stats` in a docker\ncontainer using the pre-built image.\n\n```bash\n# Download the docker-compose file\n$ curl -O https://raw.githubusercontent.com/thrawn01/channel-stats/master/docker-compose.yaml\n\n# Edit the compose file\n# environment variables\n$ vi docker-compose.yaml\n\n# Run the docker container\n$ docker-compose up -d\n\n# Hit the API at localhost:2020\n$ curl http://localhost:2020/api | jq\n```\n\n## Run locally\n* Download the release binary from [Releases Page](https://github.com/thrawn01/channel-stats/releases)\n* Download the [example yaml](https://raw.githubusercontent.com/thrawn01/channel-stats/master/channel-stats.yaml) \n* Edit the example yaml\n* Run `./channel-stats --config /path/to/config.yaml`\n* Hit the api at `curl http://localhost:2020/api | jq`\n\n## Develop\nchannel-stats uses go 1.11 modules for dependency management\n\n```bash\n$ git clone https://github.com/thrawn01/channel-stats.git\n$ cd channel-stats\n$ make\n```\n\n### Last Step!\nOnce you have provided your slack token and the bot is connected to slack, you must\ninvite the bot to a channel. It will only collect stats for channels it has been invited too!\n\n## API Documentation\nThe bot stores event counts by hour such that when querying for results all\ncalls can include a `start-hour` and an `end-hour`. If no **start** or\n **end** hour is provided then stats for the last 7 days is returned for\nthe specified channel.\n\nThe following is a list of available counter types for use with the\n `\u003ccounter\u003e` parameter.\n\nType       | Description\n-----------|------------\nmessages   | The number of messages seen in channel\npositive   | The number of messages that had positive sentiment seen in channel\nnegative   | The number of messages that had negative sentiment seen in channel\nlink       | The number of messages that contain an http link\nemoji      | The number of messages that contain an emoji\nword-count | The number of words counted in the channel\n\n**NOTE: All date / hour formats follow RFC3339 short format `2018-12-06T01`**\n\n### Retrieve Counter Totals\nCalls to `/sum` retrieve a summation of all counters for a specified duration\n\n```\nGET /api/sum\n```\n\nParameter   | Description\n------------|------------\nstart-hour  | Retrieve counters starting at this hour\nend-hour    | Retrieve counters ending at this hour\nchannel     | Channel to retrieve counters for\ncounter     | Name of the counter (See 'Counters' for valid counter names)\n\n##### Examples\nGet a count of messages for the last 7 days for channel 'general'\n```bash\n$ curl 'http://localhost:2020/api/sum?channel=general\u0026counter=messages' | jq\n{\n    \"start-hour\": \"2018-12-06T18\",\n    \"end-hour\": \"2018-12-13T18\",\n    \"items\":[\n        {\n            \"user\": \"foo\",\n            \"sum\": 20\n        },\n        {\n            \"user\": \"bar\",\n            \"sum\": 2\n        }\n    ]\n}\n```\nGet a count of negative sentiment messages since midnight\n```bash\n$ curl 'http://localhost:2020/api/sum?channel=general\u0026counter=negative\u0026start-date=2018-12-13T00'\n```\n\nGet a count of messages with emoji's in the last 2 days\n```bash\n$ curl 'http://localhost:2020/api/sum?channel=general\u0026counter=emoji\u0026start-hour=2018-12-11T00\u0026end-hour=2018-12-13T00'\n```\n\n### Retrieve Counter Percentages\nCalls to `/percentage` retrieve a summation and percentage of total messages for a specified duration. This is useful\nfor figuring out what percentage of total messages have negative or positive sentiment.\n\n```\nGET /api/percentage\n```\n\nParameter   | Description\n------------|------------\nstart-hour  | Retrieve counters starting at this hour\nend-hour    | Retrieve counters ending at this hour\nchannel     | Channel to retrieve counters for\ncounter     | Name of the counter (See 'Counters' for valid counter names)\n\n##### Examples\nGet a percent of messages that have negative sentiment the last 7 days for channel 'general'\n```bash\n$ curl 'http://localhost:2020/api/percentage?channel=general\u0026counter=negative' | jq\n{\n    \"start-hour\": \"2018-12-06T18\",\n    \"end-hour\": \"2018-12-13T18\",\n    \"items\":[\n        {\n            \"user\": \"foo\",\n            \"total\": 241,\n            \"count\": 53,\n            \"percentage\": 21\n        },\n        {\n            \"user\": \"bar\",\n            \"total\": 186,\n            \"count\": 30,\n            \"percentage\": 16\n        }\n    ]\n}\n```\n\n### Retrieve raw counter data\nYou can get access to the raw counter data via the `/datapoints` endpoint\n\n```\nGET /api/datapoints\n```\n\nParameter   | Description\n------------|------------\nstart-hour  | The start hour\nend-hour    | Then end hour\nchannel     | Channel to retrieve counters for\ncounter     | Name of the counter (See 'Counters' for valid counter names)\n\n##### Examples\nGet all the counters for the last 7 days for the `general` channel\n```bash\n$ curl 'http://localhost:2020/api/datapoints?channel=general\u0026counter=messages' | jq\n{\n    \"start-hour\": \"2018-12-06T19\",\n    \"end-hour\": \"2018-12-13T19\",\n    \"items\":[\n        {\n            \"Hour\": \"2018-12-06T21\",\n            \"UserID\": \"U02C73W94\",\n            \"UserName\": \"redbo\",\n            \"ChannelID\": \"C02C073ND\",\n            \"ChannelName\": \"general\",\n            \"DataType\": \"messages\",\n            \"Value\": 10\n        },\n        {\n            \"Hour\": \"2018-12-06T21\",\n            \"UserID\": \"U02CG0QLN\",\n            \"UserName\": \"glange\",\n            \"ChannelID\": \"C02C073ND\",\n            \"ChannelName\": \"general\",\n            \"DataType\": \"messages\",\n            \"Value\": 8\n        }\n    ]\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthrawn01%2Fchannel-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthrawn01%2Fchannel-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthrawn01%2Fchannel-stats/lists"}