Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

daemon1024
Copy link
Member

Fixes #12

@sidntrivedi012
Copy link
Member

@daemon1024 Please close and reopen the PR to run the GH Workflow tests.

@daemon1024 daemon1024 closed this Jul 10, 2020
@daemon1024 daemon1024 reopened this Jul 10, 2020
@daemon1024
Copy link
Member Author

@sidntrivedi012 I guess that should do :)

bot.Send(reply)
}

func introverify(user *tbot.User, ID int64, client mongo.Client) {
Copy link
Member

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":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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())
Copy link
Member

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 {
Copy link
Member

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`")
Copy link
Member

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.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.")

@sidntrivedi012
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementing auto-kicking members if no introduction provided in 24 hours of joining the group
2 participants