-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented auto-kicking members if no introduction provided in 24 hours of joining the group #28
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
introverify
?? 😅 Please write a better name for the function.
@@ -220,6 +191,8 @@ func main() { | |||
deletenote(ID, update.Message.Text, *client) | |||
case "fetchnote": | |||
fetchnote(ID, update.Message.Text, *client) | |||
case "introduction": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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