TwitFol

script to send tweet from random list of subreddits containing a random submission of the subreddit.

Also searches twitter for something containing a hashtag of gamejams currently happening etc.


In [36]:
from TwitterFollowBot import TwitterBot
import requests
import json
import praw
import random

In [ ]:


In [37]:
bb_bot = TwitterBot('/home/wcmckee/brobeur-tweet/brobeur.txt')

In [68]:
wcm_bot = TwitterBot('/home/wcmckee/wcm-tweet/config.txt')

In [38]:
r = praw.Reddit(user_agent='wcmckeepython')

In [69]:
wcmsubreds = ['python', 'ipython', 'webdev', 'coding', 'databases', 'hacking', 'haskell', 'linux']

In [49]:
scribred = ['writing', 'gaming', 'InternetIsBeautiful', 'Minecraft', 'skyrim', 'linux', 'opensource', 'wow']

In [70]:
wcmrasub = random.choice(wcmsubreds)

In [71]:
hashwcm = ('#' + wcmrasub)

In [50]:
randscr = random.choice(scribred)

In [51]:
hashse = ('#' + randscr)

In [52]:
getnewr = r.get_subreddit(randscr)

In [53]:
randscr


Out[53]:
'gaming'

In [73]:
getwcms = r.get_subreddit(wcmrasub)

In [74]:
twcm = getwcms.get_random_submission()

In [75]:
wtit = twcm.title

In [76]:
wurl = twcm.url

In [77]:
wcm_bot.send_tweet(wtit + ' ' + wurl + ' ' + hashwcm)


Out[77]:
{'contributors': None,
 'coordinates': None,
 'created_at': 'Thu Oct 08 04:30:58 +0000 2015',
 'entities': {'hashtags': [{'indices': [45, 53], 'text': 'ipython'}],
  'symbols': [],
  'urls': [{'display_url': 'reddit.com/r/IPython/comm…',
    'expanded_url': 'https://www.reddit.com/r/IPython/comments/2zje3g/parallel_programming/',
    'indices': [21, 44],
    'url': 'https://t.co/FtXRLA6t3p'}],
  'user_mentions': []},
 'favorite_count': 0,
 'favorited': False,
 'geo': None,
 'id': 651978066793644032,
 'id_str': '651978066793644032',
 'in_reply_to_screen_name': None,
 'in_reply_to_status_id': None,
 'in_reply_to_status_id_str': None,
 'in_reply_to_user_id': None,
 'in_reply_to_user_id_str': None,
 'is_quote_status': False,
 'lang': 'et',
 'place': None,
 'possibly_sensitive': False,
 'retweet_count': 0,
 'retweeted': False,
 'source': '<a href="http://brobeur.com" rel="nofollow">brobeurtweet</a>',
 'text': 'Parallel programming https://t.co/FtXRLA6t3p #ipython',
 'truncated': False,
 'user': {'contributors_enabled': False,
  'created_at': 'Sat Mar 30 01:44:05 +0000 2013',
  'default_profile': False,
  'default_profile_image': False,
  'description': 'Video Game Development. #gamedev #linux #getsdrawn',
  'entities': {'description': {'urls': []},
   'url': {'urls': [{'display_url': 'brobeur.com',
      'expanded_url': 'http://brobeur.com',
      'indices': [0, 22],
      'url': 'http://t.co/KRO9XPRA01'}]}},
  'favourites_count': 14,
  'follow_request_sent': False,
  'followers_count': 1058,
  'following': False,
  'friends_count': 2000,
  'geo_enabled': False,
  'has_extended_profile': False,
  'id': 1315550370,
  'id_str': '1315550370',
  'is_translation_enabled': False,
  'is_translator': False,
  'lang': 'en',
  'listed_count': 110,
  'location': 'Hamilton, New Zealand',
  'name': 'BroBeur.com',
  'notifications': False,
  'profile_background_color': 'C0DEED',
  'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png',
  'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png',
  'profile_background_tile': False,
  'profile_banner_url': 'https://pbs.twimg.com/profile_banners/1315550370/1431862528',
  'profile_image_url': 'http://pbs.twimg.com/profile_images/487211737284739072/HBzP949-_normal.png',
  'profile_image_url_https': 'https://pbs.twimg.com/profile_images/487211737284739072/HBzP949-_normal.png',
  'profile_link_color': '300808',
  'profile_sidebar_border_color': 'C0DEED',
  'profile_sidebar_fill_color': 'DDEEF6',
  'profile_text_color': '333333',
  'profile_use_background_image': True,
  'protected': False,
  'screen_name': 'brobeur',
  'statuses_count': 10222,
  'time_zone': 'Wellington',
  'url': 'http://t.co/KRO9XPRA01',
  'utc_offset': 46800,
  'verified': False}}

In [54]:
#for getr in getnewr:
#    print (getr)

In [55]:
getrsub = getnewr.get_random_submission()

In [56]:
gtia = getrsub.title

In [57]:
gurl = getrsub.url

In [58]:
bb.send_tweet(gtia + ' ' + gurl + ' ' + hashse)


Out[58]:
{'contributors': None,
 'coordinates': None,
 'created_at': 'Thu Oct 08 04:18:58 +0000 2015',
 'entities': {'hashtags': [{'indices': [93, 100], 'text': 'gaming'}],
  'symbols': [],
  'urls': [{'display_url': 'reddit.com/r/gaming/comme…',
    'expanded_url': 'https://www.reddit.com/r/gaming/comments/3nw5bo/what_rpg_game_would_you_recommend_that_runs_on_a/',
    'indices': [69, 92],
    'url': 'https://t.co/o6DjJHHDza'}],
  'user_mentions': []},
 'favorite_count': 0,
 'favorited': False,
 'geo': None,
 'id': 651975043509948416,
 'id_str': '651975043509948416',
 'in_reply_to_screen_name': None,
 'in_reply_to_status_id': None,
 'in_reply_to_status_id_str': None,
 'in_reply_to_user_id': None,
 'in_reply_to_user_id_str': None,
 'is_quote_status': False,
 'lang': 'en',
 'place': None,
 'possibly_sensitive': False,
 'retweet_count': 0,
 'retweeted': False,
 'source': '<a href="http://brobeur.com" rel="nofollow">brobeurtweet</a>',
 'text': 'What rpg game would you recommend that runs on a "badgaming" laptop. https://t.co/o6DjJHHDza #gaming',
 'truncated': False,
 'user': {'contributors_enabled': False,
  'created_at': 'Sat Mar 30 01:44:05 +0000 2013',
  'default_profile': False,
  'default_profile_image': False,
  'description': 'Video Game Development. #gamedev #linux #getsdrawn',
  'entities': {'description': {'urls': []},
   'url': {'urls': [{'display_url': 'brobeur.com',
      'expanded_url': 'http://brobeur.com',
      'indices': [0, 22],
      'url': 'http://t.co/KRO9XPRA01'}]}},
  'favourites_count': 14,
  'follow_request_sent': False,
  'followers_count': 1058,
  'following': False,
  'friends_count': 2000,
  'geo_enabled': False,
  'has_extended_profile': False,
  'id': 1315550370,
  'id_str': '1315550370',
  'is_translation_enabled': False,
  'is_translator': False,
  'lang': 'en',
  'listed_count': 110,
  'location': 'Hamilton, New Zealand',
  'name': 'BroBeur.com',
  'notifications': False,
  'profile_background_color': 'C0DEED',
  'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png',
  'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png',
  'profile_background_tile': False,
  'profile_banner_url': 'https://pbs.twimg.com/profile_banners/1315550370/1431862528',
  'profile_image_url': 'http://pbs.twimg.com/profile_images/487211737284739072/HBzP949-_normal.png',
  'profile_image_url_https': 'https://pbs.twimg.com/profile_images/487211737284739072/HBzP949-_normal.png',
  'profile_link_color': '300808',
  'profile_sidebar_border_color': 'C0DEED',
  'profile_sidebar_fill_color': 'DDEEF6',
  'profile_text_color': '333333',
  'profile_use_background_image': True,
  'protected': False,
  'screen_name': 'brobeur',
  'statuses_count': 10221,
  'time_zone': 'Wellington',
  'url': 'http://t.co/KRO9XPRA01',
  'utc_offset': 46800,
  'verified': False}}

In [59]:
#reqjok = requests.get('http://tambal.azurewebsites.net/joke/random')

In [60]:
#jsjok = reqjok.text

In [61]:
#dicjok = json.loads(jsjok)

In [62]:
#str(dicjok.values())

In [63]:
#for dicv in dicjok.values():
#    print (dicv)
#    my_bot.send_tweet(dicv)

In [64]:
#my_bot.sync_follows()

In [65]:
#my_bot.auto_unfollow_nonfollowers()

In [79]:
wcmretw = ['#ForgeConf', '#lascot15', '#code', '#programming', '#linux']

In [66]:
tweval = ['#gamedev', '#ludumdare', '#1GAM', '#gaming', '#gta', '#uncharted', '#unity3d', ]

In [78]:
bbranrt = random.choice(tweval)

In [80]:
wcretw = random.choice(wcmretw)

In [ ]:


In [67]:
bb_bot.auto_rt(tweval, count = 1 )

In [81]:
wcm_bot.auto_rt(wcretw, count= 1 )


Retweeted: b'RT @lq_feed: How to configure LDAP login http://t.co/d61Fsc8IF7 #Linux'

In [ ]: