twitter2vk is a script for automatically republishing statuses from Twitter in VK. For example, if you have old friends who do not want to leave VKontakte.
Benefits
- It does not store passwords , so the loss of the settings file will not be so terrible. In the settings, only the session ID in the contact and the data for the OAuth-login to Twitter are stored. Especially true for those who use the same password for multiple services.
- Supports retweets - publishes in Vkontakte the statuses of other users that you have withdrawn.
- Setting the format of statuses and retweets in VK. You can, for example, replace users with links to them or trim the text leaving the link after it in full: “Long text ... http // twitter.com / my / status / 31337”.
- Rules of exclusion of statuses . You can specify which statuses will not be republished in Vkontakte (for example, responses to other Twitter users).
Installation
Ideally, the script should be installed on a server that is constantly running, for example, on a
VPS or home silent media server. But you can use the working machine, but then the status will be republished only when it is turned on (however, they will not be lost).
- We put Ruby and its package manager RubyGems (command for Ubuntu / Debian):
sudo aptitude install rubygems libopenssl-ruby ruby-dev
- Install twitter2vk:
sudo gem install twitter2vk
- Run the wizard to create settings and tasks for cron:
twitter2vk
If you run the setup wizard again and specify the settings file that has already been created, the wizard will not overwrite them, but only update the login properties in V Kontakte and Twitter.
')
A wizard for creating settings and a republishing script are different packages, so settings can be created on a home computer, and only replication script can be installed on the server.
sudo gem install twitter2vk_reposter
Theoretically, the script should work under Windows. But it was tested only under OS of a type of UNIX.
Customization
The settings are saved in
YAML format, but it is quite simple.
Status format
Three properties are responsible for the status
format
:
format
,
retweet
,
last
. You can use variables in them:
%status%
- status text.%url%
- the address of the status on Twitter.%author%
- status author. It makes sense to use only in retweet format.
The
format
and
retweet
properties are used to set the appearance of regular tweet and retweet, respectively. After that, the text from
last
will be added to them.
If the resulting status is greater than the allowed one in VKontakte (160 characters),
format
or
retweet
is truncated first. Therefore, it is convenient to put a link to a tweet in the
last
so that it is not cut off (“Long text ... http // twitter.com / my / status / 31337”).
format: "% status%"
retweet: "♺% author%:% status"
last: "% url%"
Replacements
Before publishing in VK, the script can replace the necessary words. For example, remove # in front of hash tags or, instead of
user, output the link
http://twitter.com/user .
Substitutions are specified as an array
[ , ]
in the
replace
array. You can use regular expressions. Instead of an array, you can use the code
:user_to_url
to replace users with links.
replace:
- ["#nowplaying", "Now playing:"]
- [! ruby / regexp / # (\ w) /, "\ 1"]
-: user_to_url
Skip statuses
The script uses black and white list of patterns to determine whether to publish the next tweet in VKontakte -
exclude
and
include
, respectively. In them, you specify a string or regular expression that should be contained in the tweet text.
There are codes for popular tasks:
:reply
- reply to another Twitter user.:retweet
- retweet.
By default, twitter2vk will not republish the answers and tweets containing "#novk" (for example, "When all my classmates will understand what kind of Vtakte #novk").
The default whitelist is “#vk”, so if you need a tweet to be published in VKontakte, despite the rules to
exclude
them, you should write something like this: “
user Are you right? .
exclude:
-: reply
- "Facebook"
-! ruby / regexp / \ d \ d \ d \ s? \ $ /
include:
-: retweet
- "In contact with"
see also
- The page on GitHub - source code and the publication of bug reports.
- @andrey_sitnik - twitter author, where updates are posted twitter2vk.
- rvk - Ruby-library for working with VKontakte