Skip to content
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

Enforce OOP style of code #17

Open
ananyo2012 opened this issue Jun 14, 2018 · 4 comments
Open

Enforce OOP style of code #17

ananyo2012 opened this issue Jun 14, 2018 · 4 comments

Comments

@ananyo2012
Copy link

ananyo2012 commented Jun 14, 2018

You may be thinking why I am insisting OOP style in such a small script. So I start off answering the question

Why OOP ?

One of the reason I am proposing OOP is to keep the code more readable and maintainable, but the most important one is to implement Option parser.

Currently the script does 3 things

  1. Follows 100 followers of the user (optional can be disabled by --no-follow flag)
    2, Retweets and Likes the tweet
  2. Retweet with comment (optional can be disabled by --no-comment flag)
  3. Follow the user who made the tweet (optional can be disabled by --no-friendship flag)

Since we intend volunteers to use this as well, we should make everything optional since it is upto the user if he/she wants to follow a particular person or retweet with a comment. We should give the flexibility of usage.

Making the script Object Oriented is the first step towards making the code more modular.

How to implement OOP in this script ?

Just make a class named ReTweeter and move the above 4 things in separate methods. The class will look like

class ReTweeter:
  def __init__(self):
    auth= tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    self.api = tweepy.API(auth)

  def follow(self):
    pass

  def retweet(self):
    pass

  def retweet_with_comment(self):
    pass

  def make_friend(self):
    pass

def main():
  retweeeter = ReTweeter()
  retweeter.follow()
  retweeter.retweet()
  ...

Note: You don't have to use the same structure. I am just proposing an initial template

@Rohithgilla12
Copy link
Owner

Yeah, please check the OOP branch

@inovizz
Copy link
Collaborator

inovizz commented Jun 16, 2018

I'm good w/ making script modular by using OOP but looks like @ananyo2012 you were not clear on the requirements when you wrote this, I guess by the discussion we had on discord yesterday cleared the requirements.

@Rohithgilla12 @vipulgupta2048 - please refer to the discord discussion as well in case you have any doubts.

So here is what we need to do -

  1. PyConIndia Generic bot -
    Let that bot do whatever it is doing right now but change the structure of the code to OOP and make it re-usable as @ananyo2012 suggests.

  2. Volunteer Specific bot -
    Since above code would be in OOP so it can be re-used and configured for a specific volunteer to do the following:

  • A volunteer can set his/her twitter auth credentials
  • Bot Likes every tweet for @pyconindia[only] twitter handle
  • Bot retweets every @pyconindia tweet with comment - "#PyConIndia, #PyConIndia2018, #CFP, #Tickets, #PyCon, #Python"

Note - Use this module for argument parsing.

@Rohithgilla12
Copy link
Owner

Okay Sanchit will work on it :)

@joybh98
Copy link

joybh98 commented Jun 26, 2018

Is anyone working on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants