-
-
Notifications
You must be signed in to change notification settings - Fork 392
twitter_bot: Solve retweet issue. #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
# do nothing. | ||
if edit_message is True: | ||
message_data = { | ||
"message_id": message_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message_id
exists only when the try
code above doesn't raise an exception, which means it only exists within that scope. Shouldn't message_id
be initialized to have a default value of 0 first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added accordingly.
From my reading of the current state of the PR, there is no adding a number of retweets in the body of the message yet (a). What happens is that the message is being edited with the message_id pointing to the latest message. Is feature (a) too unwieldy to implement? |
@rht I am storing the |
|
The twitter bot initially posted all kind of tweets. Change it so that on encountering a retweet either post the original tweet if it hasn't been posted before. Else try to edit the number of retweets in the message of the original tweet.
if status.retweeted_status is None: | ||
config_internal.set('twitter', str(status.id), str(ret['id'])) | ||
else: | ||
config_internal.set('twitter', str(status.retweeted_status.id), str(ret['id'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that the config file content will grow larger with the number of retweeted messages? What about reading the tweet count from the message body instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am using it as a kind of database to store the message id of the message in which that tweet was published. I am reading the tweet count from the message body. I am storing the message id so that I can later edit that message if I get its retweet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the message id should be stored in a separate dedicated key-value database?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that would be better. Can you suggest what I should use for the key-value database?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't come up with any solution on top of my head. Haven't seen any being used by python-zulip-api bots before. But if other bots will become more complex to require a db, they might be using the same db we would use here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a quick search, I found pickledb, a nosql key-value db in pure python. Unfortunately I can't be decisive about this, given that there are several alternatives. Maybe we should discuss in czo.
Perhaps it will be feasible to use bot storage to store the key-value pairs. |
Heads up @orientor, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
The twitter bot initially posted all kind of tweets. Change it
so that on encountering a retweet either post the original tweet
if it hasn't been posted before. Else try to edit the number of
retweets in the message of the original tweet.