piyushchauhan / iitp-discord-bot

A discrod bot for IIT Patna community on any discord server.
2 stars 17 forks source link

Scrap a channel and find the Roll number from the message and username with tag and put that in the google spreadsheet if not already present #9

Open piyushchauhan opened 4 years ago

piyushchauhan commented 4 years ago

For example see the messages in #intro channel of Cassiopeia server at https://discord.gg/NYHj58M Steps:

Column order in the spreadsheet

Discord username tag Real Name Roll Number email House Comments
Darshilp326 commented 4 years ago

I would like to work on this issue.

piyushchauhan commented 4 years ago

@Darshilp326 Ok I am assigning it to you. You can start working on it.

piyushchauhan commented 4 years ago

Make a new command for this task in new file. !scrap rolls

piyushchauhan commented 4 years ago

One possibility to solve this. @Darshilp326

  1. get the list of all the people who are accessible to the channel in which !scrap rolls was sent.
  2. get all the messages from each person that was sent in that chennel.
  3. Perform the roll number reqular expression query on each message.
Darshilp326 commented 4 years ago

@piyushchauhan For 2nd step we need to fetch messages which will lead to older problem only.

piyushchauhan commented 4 years ago

@piyushchauhan For 2nd step we need to fetch messages which will lead to older problem only.

Most probably there won't be more than 100 msgs sent by a user in that channel. So that will work practically.

Anyways later on we can add a moderation to the channel that if the person who messaged is in the channel is already in the spreadsheet database then we can delete that message. So that it won't cause much over head in future.

Darshilp326 commented 4 years ago

@piyushchauhan there is no inbuilt function for finding a specific user's message. We need to fetch all messages of that channel and then find manually by checking that message's author id and our user's id.

Darshilp326 commented 4 years ago

@piyushchauhan one solution can be for every message we need to check if it contains roll no. But for this we don't need command !scrap-rolls.

piyushchauhan commented 4 years ago

Refer this https://support.discord.com/hc/en-us/articles/115000468588 If this is possible through Discrod.js then our job is done.

piyushchauhan commented 4 years ago

@Darshilp326 Have you tried this? https://discordjs.guide/popular-topics/collectors.html#basic-message-collector

piyushchauhan commented 4 years ago

Have you made the Regex for roll number?

Darshilp326 commented 4 years ago

^\d{4}[a-z]{2,}\d{1,3}$ regex

https://regex101.com/r/ck8jKo/21

Darshilp326 commented 4 years ago

Message collector will work ! Actually without that also if we check every message then it is similar to message collector only.

piyushchauhan commented 4 years ago

^\d{4}[a-z]{2,}\d{1,3}$ regex

https://regex101.com/r/ck8jKo/21

\d{4}[a-z]{2}\d{2} https://regex101.com/r/ck8jKo/22 This will be a better one. Always consider multiline strings when building regex

Darshilp326 commented 4 years ago

^\d{4}[a-z]{2,}\d{1,3}$ regex https://regex101.com/r/ck8jKo/21

\d{4}[a-z]{2}\d{2} https://regex101.com/r/ck8jKo/22 This will be a better one. Always consider multiline strings when building regex

Ok i will take this but i have assumed that in one message we will be getting only one roll number