Skip to content

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.

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.

@daemon1024 daemon1024 force-pushed the master branch 3 times, most recently from 5558973 to 6adc0b2 Compare November 6, 2020 18:56
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