Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Jun 17, 2021
1 parent 3147aea commit 6bb9f40
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Mattermost Random Meeting

Mattermost plugin to create random meetings. The plugin tries to avoid users you have already talked to.

## Installation

Download the latest version from [releases](https://github.com/juanfran/mattermost-random-meeting/releases).

Go to **System Console > Plugins > Management** upload and enable the plugin.

## Settings

- **Recurrence** - daily, weekly or monthly meetings.
- **Initial text** - The text that will be send to the users when is time to chat.
- **Number of users per meeting** - Minimum users per meeting.

## Usage

In any channel you can use the following command. By default you are not going to participate in any meeting until you type `/random-meeting on`.

- `/random-meeting on` - You are available to meet, you have to wait until the the plugin assign you an user group.
- `/random-meeting off` - You don't want to participate in the next recurring meetings.
- `/random-meeting pause` - Toggle meeting participation.

## Admin commands

- `/random-meeting info` - List users that are using the `random-meeting` plugin.
- `/random-meeting add @mention` - Add user.
- `/random-meeting remove @mention` - Remove user.
- `/random-meeting meetings` - Print a JSON string with the previous meetings
- `/random-meeting set_meetings [["user1", "bruce", "martha"]]` - Set the meetings that have are already happened.
10 changes: 9 additions & 1 deletion server/meetings.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ func getMeetingCandidates(userInMeeting []string, users []string, previousMeetin
}

for index, userId := range usersList {
priority[userId] = priority[userId] + (index * index) + getCountUserMeet(userMeeting, userId, previousMeetings)*2
maxCount := len(previousMeetings)
lenUsers := len(users)

if maxCount > 40 {
maxCount = lenUsers * lenUsers
}

count := getCountUserMeet(userMeeting, userId, previousMeetings[:maxCount])
priority[userId] = priority[userId] + (index * index) + (count * count)
}
}

Expand Down
11 changes: 4 additions & 7 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,20 @@ func (p *Plugin) addCronFunc() {
func (p *Plugin) runMeetings() {
users := p.getAvailableUsers()

// todo
reverseAny(p.usersMeetings)

meetings := getMeetingsShuffleUsers(users, p.configuration.NumUsersPerMeeting, p.userMeetingsReversed)
meetings := getMeetingsShuffleUsers(users, p.configuration.NumUsersPerMeeting, p.usersMeetings)

for _, meeting := range meetings {
p.startMeeting(meeting)
}
}

func (p *Plugin) startMeeting(meeting []string) {
maxMeetings := 50
maxMeetings := 100

p.usersMeetings = append(p.usersMeetings, meeting)
p.usersMeetings = PrependSlice(p.usersMeetings, meeting)

if len(p.usersMeetings) > maxMeetings {
_, p.usersMeetings = p.usersMeetings[0], p.usersMeetings[1:]
p.usersMeetings = p.usersMeetings[:len(p.usersMeetings)-1]
}

users := append(meeting, p.botUserID)
Expand Down
5 changes: 2 additions & 3 deletions server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ func Prepend(data []string, item string) []string {
return data
}

// todo
func PrependSlice(data []string, prepend []string) [][]string {
data = append([][]string{prepend}, data...)
func PrependSlice(data [][]string, item []string) [][]string {
data = append([][]string{item}, data...)
return data
}

Expand Down

0 comments on commit 6bb9f40

Please sign in to comment.