analog-nico / twitter-reply-bot

A Twitter bot which finds tweets that match your search terms and replies with responses you prepared. Useful for engaging with new people on a certain topic.
ISC License
39 stars 18 forks source link

How to import Random Settings #2

Open jessi19 opened 8 years ago

jessi19 commented 8 years ago

Hi, First , thanks for Sharing this Bot. i am not Pro in in Programming so i have few doubts about using this Bot. i have successfully set up the bot with my Twitter account, i have 2 different twitter accounts one for my blog and one for Personal account. i am using this bot to Replay to tweets that mention my blog. Since i have two accounts i created 2 Settings.json files. i want to import any one of settings file randomly every time the bot runs. so that i can reply to users with my Personal account or with my blog. i dont know how to Import the settings.json file randomly can anyone help me

analog-nico commented 8 years ago

I think it is easier to extend the settings.json rather than creating two files. What you need is a second pair of access_token_key and access_token_secret. The only place where those are used is in request.js.

Since you probably get the second access_token_key and access_token_secret by creating another app for your second Twitter account you get different consumer_key and consumer_secret for that.

So you may start with this settings.json format where twitter_api becomes an array and then update request.js accordingly:

{
  "twitter_api": [
    {
      "consumer_key":        "TODO: Set according to https://apps.twitter.com -> create app -> tab 'Keys and Access Tokens' -> Application Settings -> Consumer Key (API Key)",
      "consumer_secret":     "TODO: Set according to https://apps.twitter.com -> create app -> tab 'Keys and Access Tokens' -> Application Settings -> Consumer Secret (API Secret)",
      "access_token_key":    "TODO: Set according to https://apps.twitter.com -> create app -> tab 'Keys and Access Tokens' -> Your Access Token -> Access Token",
      "access_token_secret": "TODO: Set according to https://apps.twitter.com -> create app -> tab 'Keys and Access Tokens' -> Your Access Token -> Access Token Secret"
    },
    {
      "consumer_key":        "TODO: Set according to https://apps.twitter.com -> create app -> tab 'Keys and Access Tokens' -> Application Settings -> Consumer Key (API Key)",
      "consumer_secret":     "TODO: Set according to https://apps.twitter.com -> create app -> tab 'Keys and Access Tokens' -> Application Settings -> Consumer Secret (API Secret)",
      "access_token_key":    "TODO: Set according to https://apps.twitter.com -> create app -> tab 'Keys and Access Tokens' -> Your Access Token -> Access Token",
      "access_token_secret": "TODO: Set according to https://apps.twitter.com -> create app -> tab 'Keys and Access Tokens' -> Your Access Token -> Access Token Secret"
    }
  ],
  "database": {
    "url": "mongodb://... TODO: See http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html#the-url-connection-format",
    "collection": "users"
  },
  "bot_parameters": {
    "query": "TODO: See 'Query Operators' in https://dev.twitter.com/rest/public/search",
    "lang": "en",
    "replyOnceEveryXMinutes": 15,
    "replyToTweetsAtLeastXMinutesOld": 5
  }
}
jessi19 commented 8 years ago

i am sorry i don't know how to update request.js, to work with new Settings File, i have made changes to Settings.json file like the above Example. but i dont know how to change request.js file can you help me. Thanks for Responding..

analog-nico commented 8 years ago

It is all about setting the credentials variable right. Also _.random(0,1) will be helpful. You can do it!

jessi19 commented 8 years ago

Sorry i dont know much about Programming. i understand, i need to change this line in requests.js var credentials = require('../settings.json').twitter_api; i have no idea how to do that.is there any tutorials for that part.

analog-nico commented 8 years ago

If you want to use custom automation like this you should definitely learn programming! Since I gave you all breadcrumbs all that is remaining is basic JavaScript programming. I encourage you to try your best!