A3: Trolling a Reply Bot#
Choose Social Media Platform: Reddit | Discord | Bluesky | No Coding
In this assignment, your job will be to modify the reply bot below (see section Demo: Trolling a Reply Bot) and make your own version of a reply bot (look for the TODO
section below). Then after you’ve modified it, see if you can troll it. At the end, you will have some reflection questions to answer.
When you are done, you will need to download this file (file menu -> download) and turn it in on Canvas.
Below is the code for the first reply bot from the book, where if you message it:
Subject: “Wanting bot response”, body: “I want you to ___” (where the ___ is some action)
then the bot will reply, “I will now ____” (where the ___ is that same action).
Sending ourselves a message#
In order to send ourselves a message we can reply to, go to:
Then compose a message to your own account with the subject:
Wanting bot response and a message body of something like:
I want you to jump
TODO: Modify this section (If message matches our pattern, reply)#
You must must modify at least one thing in the code below. You could change the expected patterns, or you could change the code that replies, or you could change both.
We will now see if the message matches our pattern of a message subject of “Wanting bot response” with a message body of “I want you to ___” and then we will reply.
First we will create strings with the patterns we are looking for and save them into variables.
expected_subject = "Wanting bot response"
expected_body_pattern = "I want you to "
We will check if the message has the subject we are expecting. If it does it will check if the essage body starts with the expected pattern. If it does, then we will find the action from the end of the message body text (based on the expected_pattern length), and reply using that action.
We also add “else” cases for when we didn’t match the patter, and display a message saying what didn’t match.
# check if the mention text starts with our set phrase
if latest_message.subject == expected_subject:
if latest_message.body.startswith(expected_body_pattern):
# get the action, which should be the end of the string after the expected pattern
action = latest_message.body[len(expected_body_pattern) :]
# make a new message which says we will do the action
message = "I will now " + action
# send our message in reply
latest_message.reply(message)
else: # else code for if the message body didn't match
display("The message body (" + latest_message.body + ") didn't match our pattern (" + expected_body_pattern + ")")
else: # else code for if the message subject didn't match
display("The message subject (" + latest_message.subject + ") didn't match our expected subject (" + expected_subject + ")" )
Reflection questions#
What changes did you make to the reply bot?
TODO: Write your answer here
How could you troll this bot? Give an example of a message that would let you troll it. Or, if you don’t think it can be trolled, explain why.
TODO: Write your answer here
What limitations does trying to prevent trolling put on your ability to create a bot? (write at least 3 sentences)
TODO: Write at least 3 sentences here
Pick two ethics frameworks and compare how they might evaluate the responsibility of someone who is creating a reply bot? (write at least 6 sentences total)
TODO: Write at least 6 sentences here
Pick two ethics frameworks and compare how they might evaluate the responsibility of someone who is considering trolling a reply bot? (write at least 6 sentences total)
TODO: Write at least 6 sentences here