使用PRAW库,当提及给定关键字时,reddit bot会在子线程中回复帖子标题。我想进行更改,以便在评论中而不是帖子中的答复中提及它。
@override
dialogContent(BuildContext context) {
return Stack(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: Consts.avatarRadius + Consts.padding,
bottom: Consts.padding,
left: Consts.padding,
right: Consts.padding,
),
margin: EdgeInsets.only(top: Consts.avatarRadius),
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(Consts.padding),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 10.0,
offset: const Offset(0.0, 10.0),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
title,
style: TextStyle(
fontSize: 28.0,
fontWeight: FontWeight.bold,
fontFamily: "Rubik1",
),
),
SizedBox(height: 16.0),
Container(
child: ListView(
shrinkWrap: true,
children: <Widget>[
Text(
description,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24.0,
fontFamily: "Rubik1",
),
),
SizedBox(height: 24.0),
Align(
alignment: Alignment.center,
child: RaisedButton(
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(16.0),
side: BorderSide(color: Colors.blue)),
onPressed: () {
Navigator.of(context).pop(); // To close the dialog
},
textColor: Colors.white,
color: Colors.blue,
child: Text(
buttonText,
style: TextStyle(
fontSize: 24.0, fontWeight: FontWeight.bold),
),
),
),
],
),
),
],
),
),
Positioned(
left: MediaQuery.of(context).size.width / 4,
child: CircleAvatar(
backgroundImage: AssetImage(picture),
radius: Consts.avatarRadius,
backgroundColor: Colors.transparent,
)),
],
);
}
答案 0 :(得分:0)
如果您只想处理注释更改:
for submission in subreddit.stream.submissions():
process_submission(submission)
收件人:
for comment in subreddit.stream.comments():
process_comment(comment)
# def process_comment you have to write yourself
如果您要处理评论和提交,请执行以下操作:
while True:
for submission in subreddit.stream.submissions(pause_after=-1):
process_submission(submission)
for commentin subreddit.stream.comments(pause_after=-1):
process_comment(comment)
process_comment()
的示例:
def process_comment(comment):
for question_phrase in QUESTIONS:
if question_phrase in comment.body.lower():
comment.reply("Hello")