twitter2vk - from Twitter to Vkontakte

    twitter2vk - a script for automatically republishing statuses from Twitter to VKontakte. For example, if you still have old friends who do not want to leave VK.


    • It does not store passwords , so losing the settings file will not be so scary. Only the session ID in VKontakte and the data for the OAuth-login to Twitter are stored in the settings. Especially relevant for those who use the same password for several services.
    • Supports retweets - publishes in VK the statuses of other users that you retweeted.
    • 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 its entirety: “Long tex ... http // / my / status / 31337”.
    • Rules for the exclusion of statuses . You can specify which statuses will not be published in VK (for example, responses to other Twitter users).


    Ideally, the script should be installed on a server that is constantly running, for example, on a VPS or a quiet home media server. But you can use a 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 RubyGems package manager (command for Ubuntu / Debian):
      sudo aptitude install rubygems libopenssl-ruby ruby-dev
    2. Install twitter2vk:
      sudo gem install twitter2vk
    3. We launch the wizard to create the settings and tasks for cron:

    If you run the setup wizard again and specify the settings file that has already been created, the wizard will not overwrite them, it will only update the properties for logging in to VKontakte and Twitter.

    The wizard for creating the settings and the republishing script are different packages, so the settings can be created on the home computer, and only the republishing
    sudo gem install twitter2vk_reposter

    script can be installed on the server. Theoretically, the script should work under Windows. But it was tested only under OS of the UNIX type.


    Settings are saved in YAML format , but it is quite simple.

    Status Format

    For the format of the status of responsible three properties: format, retweet, last. You can use variables in them:
    • %status% - status text.
    • %url% - The status address on Twitter.
    • %author%- author of the status. It makes sense to use only in retweets.

    Properties formatand retweetare used to set the appearance of a regular tweet and retweet, respectively. After that, the text from will be added to them last.

    If the resulting status is more than acceptable in VK (160 characters), then it is truncated first formator retweet. Therefore, lastit’s convenient to place a link to a tweet so that it does not get cropped (“Long text ... http // / my / status / 31337”).

    format: "% status%"
    retweet: "♺% author%:% status"
    last: "% url%"


    Before publishing to VKontakte, the script can replace the necessary words. For example, remove # before the hash tags or instead of user display the link .

    Substitutions are indicated as an array in an array . You can use regular expressions. Instead of an array, you can use code to replace users with links.[паттер, результат]replace:user_to_url

    - ["#nowplaying", "Now playing:"]
    - [! ruby ​​/ regexp / # (\ w) /, "\ 1"]
    -: user_to_url

    Skipping Statuses

    The script uses black and white list of patterns to determine whether to publish the next tweet in VK - excludeand include, respectively. In them you indicate the line or regular expression that should be contained in the text of the tweet.

    There are codes for popular tasks:
    • :reply - A response to another Twitter user.
    • :retweet - retweets.

    By default, twitter2vk will not republish answers and tweets containing “#novk” (for example, “When will all my classmates understand what #novk sucks in VKontakte”).

    The default whitelist is “#vk”, so if you need a tweet to be published in VKontakte, despite the rules exclude, you should write something like this: “ user You are right, VKontakte really seriously lags behind Facebook #vk”.

    -: reply
    - Facebook
    -! ruby ​​/ regexp / \ d \ d \ d \ s? \ $ /
    -: retweet
    - "In contact with"

    see also

    • Page on GitHub - sources and publication of bug reports.
    • @andrey_sitnik - the author’s twitter, where twitter2vk updates are published.
    • rvk - Ruby library for working with Vkontakte

    Also popular now: