Package 'tweetrbot'

Title: Functions for a Twitter bot
Description: Functions to allow retrieve, store and retweet regularly.
Authors: Sebastien Rochette [aut, cre]
Maintainer: Sebastien Rochette <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1
Built: 2024-10-05 02:56:17 UTC
Source: https://github.com/statnmap/tweetrbot

Help Index


Filter dataset for last month tweets only

Description

Filter dataset for last month tweets only

Usage

filter_month(x, the_month, the_year)

Arguments

x

Dataset of tweets

the_month

Number of the month. Default to last month.

the_year

Year to filter. Default to current year.


Retrieve number of followers and tweets

Description

Retrieve number of followers and tweets

Usage

get_account_info(
  user = "talk_rspatial",
  dir = ".",
  timeline_file = "timeline_rspatial.rds",
  log = TRUE,
  logfile = "rtweet_info.log",
  token = NULL
)

Arguments

user

user names or user IDs

dir

Directory where to save data

timeline_file

timeline filename relative to dir

log

Logical. log file

logfile

lofile name relative to dir

token

Every user should have their own Oauth (Twitter API) token. By default token = NULL this function looks for the path to a saved Twitter token via environment variables (which is what 'create_token()' sets up by default during initial token creation). For instruction on how to create a Twitter token see the tokens vignette, i.e., 'vignettes("auth", "rtweet")'.


Retrieve tweets and store locally

Description

Retrieve tweets and store locally

Usage

get_and_store(
  query = "#rspatial",
  n_tweets = 20,
  dir = ".",
  tweets_file = "tweets_rspatial.rds",
  complete_tweets_file = "complete_tweets_rspatial.rds",
  log = TRUE,
  logfile = "rtweet_console.log",
  loop_pid_file = "loop_pid.log",
  token = NULL,
  hashtags_max = 5,
  hashtag_stopwords = "robot"
)

Arguments

query

search tweet query

n_tweets

n_tweets

dir

Path where everything will be saved

tweets_file

tweets_file path name relative to dir

complete_tweets_file

complete_tweets_file path name relative to dir

log

Logical

logfile

logfile path name relative to dir

loop_pid_file

loop_pid_file path name relative to dir

token

Every user should have their own Oauth (Twitter API) token. By default token = NULL this function looks for the path to a saved Twitter token via environment variables (which is what 'create_token()' sets up by default during initial token creation). For instruction on how to create a Twitter token see the tokens vignette, i.e., 'vignettes("auth", "rtweet")'.

hashtags_max

Maximum number of hashtags allowed in tweets

hashtag_stopwords

Hashtags that you dont want to retweet


What is last month

Description

What is last month

Usage

last_month()

Examples

last_month()

Retweet and update the database of tweets to tweet

Description

Retweet and update the database of tweets to tweet

Usage

retweet_and_update(
  dir = ".",
  tweets_file = "tweets_rspatial.rds",
  complete_tweets_file = "complete_tweets_rspatial.rds",
  log = TRUE,
  logfile = "rtweet_console.log",
  loop_pid_file = "loop_pid.log",
  tweets_failed_file = "tweets_failed_rspatial.rds",
  n_tweets = 20,
  n_limit = 3,
  sys_sleep = 600,
  debug = FALSE,
  token = NULL
)

Arguments

dir

Directory where everything will be saved

tweets_file

tweets_file path name relative to dir

complete_tweets_file

complete_tweets_file path name relative to dir

log

Logical

logfile

logfile path name relative to dir

loop_pid_file

loop_pid_file path name relative to dir

tweets_failed_file

tweets_failed_file path name relative to dir

n_tweets

n_tweets

n_limit

n_limit

sys_sleep

sys_sleep

debug

Logical. Use TRUE to avoid tweeting while debugging

token

Every user should have their own Oauth (Twitter API) token. By default token = NULL this function looks for the path to a saved Twitter token via environment variables (which is what 'create_token()' sets up by default during initial token creation). For instruction on how to create a Twitter token see the tokens vignette, i.e., 'vignettes("auth", "rtweet")'.


Create a tweet for top retweets and other stats

Description

Create a tweet for top retweets and other stats

Usage

top_tweets(
  all_tweets,
  save_dir = tempdir(),
  post_tweet = TRUE,
  top_number = 5,
  hashtag = "rspatial",
  fill = c("#1e73be", "#BF223C", "#79C698"),
  token = NULL,
  the_month_name
)

Arguments

all_tweets

Table of tweets to explore

save_dir

Path where to save images that will be tweet

post_tweet

Logical. Whether to really tweet the content

top_number

Numeric. Number of best retweeted tweets to show on the graph

hashtag

Character. Which Twitter hashtag is followed

fill

Vector of colors to be used in the graphics. Length 1 for all the same, or length 3 resp. for: top retweeted, tweets per day, contributors per day

token

Expert use only. Use this to override authentication for a single API call. In most cases you are better off changing the default for all calls. See auth_as() for details.

the_month_name

Character. Month name that appear on graph. Default to last month name.


Update a tweet dataset with last information

Description

Update information of all statuses listed. At most, the last 90000.

Usage

update_data(
  x,
  path,
  statuses,
  token = NULL,
  return_all = FALSE,
  overwrite = TRUE
)

Arguments

x

dataset to update. Not used if path is set.

path

Path to .rds file with saved dataset

statuses

Tweet statuses to update

token

Expert use only. Use this to override authentication for a single API call. In most cases you are better off changing the default for all calls. See auth_as() for details.

return_all

Logical. TRUE returns the complete dataset, FALSE returns data in statuses list (default).

overwrite

Logical. Whether to overwrite rds file with updated data