CSC510-Group-25 / ClassMateBot

This project helps to improve the life of students, TAs and teachers by automating many mundane tasks which are sometimes done manually on Discord. This is release version 3 of the ClassMateBot.
MIT License
0 stars 5 forks source link

Q&A Commands #82

Closed snapcat closed 2 years ago

snapcat commented 2 years ago

Summary

~Added 5 new commands, 41 unit tests, and set up for ghost handling.~ ~qanda.py coverage increased from 35% to 92%~

New commands:

$getAnswersFor (num) -- get all answers for a question. Ignores ghosts and zombies. $DALLAF (num) -- deletes all answers for a question. Instructor only. $archiveQA -- sends all questions and answers to the user via DM. Ignores ghosts and zombies. $deleteAllQA: deletes all questions and answers from the database and channel. Also cleans up ghosts and zombies. Instructor only. $deleteQuestion (num): deletes a single question from the channel and leaves a database ghost. Instructor only.

Round 2 was supposed to be the database integrity update, but it was included here. (Finished on 11/19, included on 11/21)

$spooky: Used to check the number of zombies and ghosts in the channel. Fun for students, practical for instructors. $channelGhost (num): Get the ghost question and its answers with that number. Also works for zombies and non-ghost questions. (Basically, getAnswersFor but doesn't ignore ghosts or zombies.) Instructor only. $allChannelGhosts: get all channel ghosts via DM. Instructor only. $reviveGhost (num): Restores a ghost question (and answers). Instructor only. $unearthZombies: gets all zombies (manually deleted questions) and assigns ghost status. Instructor only.

NOTE:

Ghosts are questions that have been "hidden" via the deleteQuestion command and can be restored. They're flagged as ghosts in the database.

Zombies are questions that have been manually deleted. They don't have ghost status so they won't show up with the allChannelGhosts command. Using reviveGhost on a zombie basically reposts the question to the channel and updates the msg_id in the database.

Changed Files

qanda.py

New commands:

$getAnswersFor (num)
$DALLAF (num)
$archiveQA
$deleteAllQA
$deleteQuestion (num)
$spooky
$channelGhost (num)
$allChannelGhosts
$reviveGhost (num)
$unearthZombies

Added regex to all functions that require a num arg to only allow valid input Added is_ghost column to questions table in init.sql (AND to the database itself) Users can now use "anon" when answering/asking questions Fixed bug that allowed users to ask empty/blank/whitespace only questions

test_bot.py: Added 70 unit tests: exhaustive, see Datebase integrity update, ghost commands, unit tests

init.sql: Added is_ghost column to questions table

Checklists


Closing Issues

Please leave a comment on these issues before approving this PR.

Resolves #79 Q&A bug: empty strings are allowed Resolves #70 qanda.py: Increase coverage to at least 75% Resolves #64 Allow users to type "anon" or "anonymous" for Q&A Resolves #10 Enhance Q and A Resolves #11 Command to list all of the questions and answers Resolves #12 Allow deleting questions/answers Resolves #13 Allow users to get a specific question

Bugs, Notes

~Ghosts will be handled in Q&A round 2.~

[Added commands: getAnswersFor, deleteAllAnswersFor](https://github.com/CSC510-Group-25/ClassMateBot/commit/191882fe9435f110bf160d634218120d2ec0fc85) [Added archiveQA command, unit tests ](https://github.com/CSC510-Group-25/ClassMateBot/pull/82/commits/7bff7fff1ba63111cb8a9635b13b1a38ba7d0199) [New commands: deleteAllQA, deleteQuestion](https://github.com/CSC510-Group-25/ClassMateBot/pull/82/commits/eb0e02fc6dab9f770c46743c69854e95e3c657b3) [](https://github.com/CSC510-Group-25/ClassMateBot/pull/82/commits/58b7ae683965d12ff2a08674631b07e4dcf8acc4) [Datebase integrity update, ghost commands, unit tests](https://github.com/CSC510-Group-25/ClassMateBot/pull/82/commits/fd0a38c940e4aa44d620c201f487ac2c1674e13c) #### Contributors @snapcat
codecov-commenter commented 2 years ago

Codecov Report

Merging #82 (f4c966b) into main (0202c8f) will increase coverage by 14.53%. The diff coverage is 97.20%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main      #82       +/-   ##
===========================================
+ Coverage   72.97%   87.50%   +14.53%     
===========================================
  Files          11       11               
  Lines         729     1329      +600     
===========================================
+ Hits          532     1163      +631     
+ Misses        197      166       -31     
Impacted Files Coverage Δ
cogs/qanda.py 95.56% <95.76%> (+60.56%) :arrow_up:
test/test_bot.py 99.19% <100.00%> (+1.00%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0202c8f...f4c966b. Read the comment docs.