How to make a reddit bot invoke a username using PRAW
<p>I have been playing with PRAW to build reddit bots. While it is easy to build a bot that auto responds generic messages to triggered keywords, I want to build something that is a bit more interactive.</p>

<p>I am trying to build a reddit bot that invokes the username of the redditor it is replying to. Eg redditor /u/ironman666 posts "good morning", I want the bot to auto respond "good morning to you too! /u/ironman666". How can I make this work? Thanks!</p>

<p>Sample code: where and how do I invoke the triggering user's name?</p>

<pre><code>import praw
import time
from praw.helpers import comment_stream

r = praw.Reddit("response agent")
r.login()


target_text = "Good Morning!"
response_text = "Good Morning to you too! #redditor name go here "



processed = []
while True:
    for c in comment_stream(r, 'all'):   
        if target_text == c.body.lower() and c.id not in processed: 
            print('Wiseau bot activated! :@')
            c.reply(response_text)
            processed.append(c.id)   #then push the response 
            time.sleep(2)
</code></pre>

<p>If you <a href="http://praw.readthedocs.io/en/stable/pages/comment_parsing.html?highlight=author#deleted-comments" rel="nofollow">read the docs</a> you'll see that the comment has an <code>author</code> attribute (unless it was deleted), so you should be able to do:</p>

<pre><code>response_text = 'Good morning to you too, {}!'
...
c.reply(response_text.format(c.author))
</code></pre>

python bots reddit praw