⬆️ ⬇️

twitter2vk - from Twitter to VKontakte





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







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).

  1. We put Ruby and its package manager RubyGems (command for Ubuntu / Debian):

    sudo aptitude install rubygems libopenssl-ruby ruby-dev
  2. Install twitter2vk:

    sudo gem install twitter2vk
  3. 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:



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:



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



Source: https://habr.com/ru/post/88386/



All Articles