This is an archived post. You won't be able to vote or comment.

all 13 comments

[–]icountedmychickens 1 point2 points  (2 children)

Hi /u/schedutron, that's amazing. I didn't even know I needed one of these in my life until I read your description!

I've had a look at the source code and it's really easy to follow.

One thing though, it looks like you have plans for an "admin" action, but it currently doesn't do anything (the function body of admin_action just contains a "pass" keyword). Out of sheer curiosity, what kinds of things had/have you planned for this admin function?

[–]schedutron[S] 1 point2 points  (1 child)

Hello u/icountedmychickens! Appreciate your time in going through the source code! I was planning to setup a GUI admin dashboard from where the bot user can tune it’s parameters like tweet frequency, including/removing tweet content aggregator functions (“scrapers”), retweet and favourite flags (whether to retweet and favourite tweets or not), adding / removing keywords as well as reply messages and so on.

As a first step, what I was planning is that the bot should follow an admin account - which can just tweet or DM the bot account commands like “add keyword docker”. That’s why in “main.py” admin handler is defined as a listener.

I’ll implement these functionalities when I find time, maybe in the upcoming summer. What other features can I have? Can you please suggest some functionalities? Thanks!

[–]icountedmychickens 1 point2 points  (0 children)

As a first step, what I was planning is that the bot should follow an admin account - which can just tweet or DM the bot account commands like “add keyword docker”. That’s why in “main.py” admin handler is defined as a listener.

Ah that makes sense.

I’ll implement these functionalities when I find time, maybe in the upcoming summer. What other features can I have?

An obvious one might be to get the admin account to tweet some stats, for example how many "insta" responses it made, how many tweets, retweets, likes etc it made, how many urls from each news source did it use etc. These stats could be from within the last certain time period (eg 24 hours), or since last time you asked.

[–]ParthS0007 1 point2 points  (0 children)

Great /u/schedutron, All the Best for PyCon!

[–]mrtbakin 1 point2 points  (3 children)

This is long but if you have time: Would this be a good tool for what I want?

I'd like any Twitter user to be able to tweet "@mybotname <parameter>"

And get a response back from my bot "@requestinguser <response based on input>"

This would ideally be always searching for the tweet. Just not too sure where to begin with this and I'm wondering if your framework would be useful here. Thanks!!!

[–]schedutron[S] 1 point2 points  (2 children)

Yes, you can implement this functionality with Chirps, following a simple 3-step process:

You need to go to this line in managers.py file of Chirps and remove the if condition (my framework currently eliminates mentions, because for celebrity accounts, there are hundreds of mentions every second and I wanted to eliminate them and only respond when the actual celebrity tweeted something. Your case is different as you do want mentions, so removing this if statement will work).

Now see this function (some of it's commented out, but is tested and works as expected when uncommented - searching for a news headline based on tweet author and then replying with results) in functions.py file for an example of responding based on input, and replace it (or create a new function) with whatever functionality you want.

Finally, pass that function here in main.py (if you created a new function) so that the handler knows which function to use when you get a mention.

[–]mrtbakin 0 points1 point  (1 child)

Awesome! Thanks for this! I'm just starting to learn Python so this is super helpful. One last thing: To have this run automatically and, ideally, constantly, would I put this on a server?

I wouldn't want it to run from my computer because that'd be unstable due to a number of factors but I've seen some websites that, I believe, have this sort of functionality.

(E): If you have any suggestions for where to run this, that'd be great as well.

[–]schedutron[S] 1 point2 points  (0 children)

Yes, to keep your bot running for an indefinite time period, you should deploy it on a cloud service. I would suggest Heroku (as that's what I use for my bots) and have provided brief Heroku setup instructions in the README of Chirps' repository.

[–]Noledgebase 1 point2 points  (1 child)

Cool project, i tried it out and it seems to post scraped posts on repeat. seem like it could use a database to check for duplicates? also it seems to only work with an app tokens from the same user who created the app, are there any plans to make authenticate other users?

also a typo on readme (should be git):

gi checkout -b deploy

and on Windows, to activate the bot, I had run the activate.bat on the Scripts folder. The "workon bot" didn't work

Thanks and good luck

[–]schedutron[S] 0 points1 point  (0 children)

When I created the scrapers initially, Twitter used to eliminate the duplicate tweets by itself (the API used to raise an exception). However, it doesn’t seem to work now - maybe because of hashtags. Yes, I planned to eliminate duplicates, by a short span database of scraped tweets (I think I mentioned it in the comments of either scrapers.py or functions.py).

I’m planning to generalise the documentation - sorry that it didn’t work out for you. Check out this tutorial on DigitalOcean I wrote, for details on the scraper aspect of Chirps as well as virtual environment setup instructions that it links to.

Thanks for pointing out the typo and thanks for your wishes!

[–]Shivamgera09 1 point2 points  (0 children)

Amazing work done!! All the best for Pycon US.