Implemented auto-kicking members if no introduction provided in 24 hours of joining the group#28
Implemented auto-kicking members if no introduction provided in 24 hours of joining the group#28daemon1024 wants to merge 3 commits intoosdc:masterfrom
Conversation
|
@daemon1024 Please close and reopen the PR to run the GH Workflow tests. |
|
@sidntrivedi012 I guess that should do :) |
| bot.Send(reply) | ||
| } | ||
|
|
||
| func introverify(user *tbot.User, ID int64, client mongo.Client) { |
There was a problem hiding this comment.
introverify?? 😅 Please write a better name for the function.
| deletenote(ID, update.Message.Text, *client) | ||
| case "fetchnote": | ||
| fetchnote(ID, update.Message.Text, *client) | ||
| case "introduction": |
There was a problem hiding this comment.
| case "introduction": | |
| case "intro": |
| if result.MatchedCount > 0 { | ||
| bot.Send(tbot.NewMessage(ID, "Thanks for introducing yourself, You are now a verified member of OSDC :) ")) | ||
| } else { | ||
| bot.Send(tbot.NewMessage(ID, "No need to introduce again, I already know you.")) |
There was a problem hiding this comment.
| bot.Send(tbot.NewMessage(ID, "No need to introduce again, I already know you.")) | |
| bot.Send(tbot.NewMessage(ID, "Thanks but no need to introduce again, I already know you.")) |
|
|
||
| } | ||
|
|
||
| func introkick(ID int64, client mongo.Client) { |
There was a problem hiding this comment.
| func introkick(ID int64, client mongo.Client) { | |
| func noIntroKick(ID int64, client mongo.Client) { |
| if err != nil { | ||
| log.Fatal(err) | ||
| } else { | ||
| // log.Println(time.Now().Local().Day(), result.JoinDate.Day()) |
There was a problem hiding this comment.
Please remove the stale comments
| curDay := time.Now().Local().Day() | ||
| User := fmt.Sprintf("[%v](tg://user?id=%v)", result.FirstName, result.UserID) | ||
| log.Println(curDay-result.JoinDate.Day(), curHour-result.JoinDate.Hour()) | ||
| if (curDay-result.JoinDate.Day() > 0 && curHour-result.JoinDate.Hour() > 0) || curDay-result.JoinDate.Day() > 1 { |
There was a problem hiding this comment.
Does the Day return the date? In that case, if curDay is 1 and JoinDate.Day() is 31. The result may be negative.
Try taking the mod of difference if that's the case.
| if (curDay-result.JoinDate.Day() > 0 && curHour-result.JoinDate.Hour() > 0) || curDay-result.JoinDate.Day() > 1 { | ||
| go kickUser(result.UserID, ID) | ||
| collection.DeleteOne(context.TODO(), bson.M{"userid": result.UserID}) | ||
| reply := tbot.NewMessage(ID, User+" kicked. `Reason : No introduction within 24 hours of joining`") |
There was a problem hiding this comment.
Also, please make the deadline as 48 hours
| reply.ParseMode = "markdown" | ||
| bot.Send(reply) | ||
| } else { | ||
| reply := tbot.NewMessage(ID, User+", Please introduce yourself in the next 12 hours or I will not be able to verify your presence and will have to kick you.") |
There was a problem hiding this comment.
| reply := tbot.NewMessage(ID, User+", Please introduce yourself in the next 12 hours or I will not be able to verify your presence and will have to kick you.") | |
| reply := tbot.NewMessage(ID, User+", Hey, This is your friendly osdc-bot. Please introduce yourself on the OSDC group in the next 12 hours or I will not be able to verify your presence and will have to kick you. Just a simple introduction about your interests, experience will be enough.") |
|
@daemon1024 Since its a quite dangerous feature, thus it will be great if you or anyone can write tests for it too. Not necessarily in this PR. But, writing tests will help to validate this feature in a better way. |
5558973 to
6adc0b2
Compare
Fixes #12