https://github.com/wilk/twitter-relay-telegram
A Twitter-to-Telegram relay
https://github.com/wilk/twitter-relay-telegram
elixir telegram telegram-bot tutorial twitter
Last synced: 10 months ago
JSON representation
A Twitter-to-Telegram relay
- Host: GitHub
- URL: https://github.com/wilk/twitter-relay-telegram
- Owner: wilk
- License: mit
- Created: 2018-04-15T17:09:34.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-30T15:10:59.000Z (almost 8 years ago)
- Last Synced: 2025-03-23T19:23:55.022Z (about 1 year ago)
- Topics: elixir, telegram, telegram-bot, tutorial, twitter
- Language: Elixir
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Tweetrelay
This is an application implemented by myself to learn and understand Elixir.
It's meant to be used as a tutorial for beginners.
Feel free to improve source code and docs.
## Setup
First, rename `.env.default` in `.env`:
```bash
$ mv .env.default .env
```
Then, replace the default vars with your credentials (Twitter and Telegram)
## Running
Just use `docker-compose` to run it:
```bash
$ docker-compose up
```
## Tutorial
Firstly, I've used `mix` to setup the project structure:
```bash
$ mix new tweetrelay
```
[mix](https://hexdocs.pm/mix/Mix.html) is the official build tool of Elixir.
With `mix new` you're able to create a new Elixir app scaffolder.
Then, I've configured the application using the `config/config.exs` file, that is used from the main application to load specific configurations.
Inside I've used `System.get_env()` function to retrieve the environment variables from the `.env` file:
```elixir
config :extwitter, :oauth, [
consumer_key: System.get_env("TWITTER_CONSUMER_KEY"),
consumer_secret: System.get_env("TWITTER_CONSUMER_SECRET"),
access_token: System.get_env("TWITTER_ACCESS_TOKEN"),
access_token_secret: System.get_env("TWITTER_ACCESS_SECRET")
]
```
Those configurations are used to configure the [ExTwitter](https://github.com/parroty/extwitter) library, used to search tweets inside Twitter's network.
```elixir
config :nadia, token: System.get_env("TELEGRAM_BOT_TOKEN")
```
While this configuration is used to configure [Nadia](https://github.com/zhyu/nadia), a library for interacting with Telegram's API.
### Adding dependencies
It's time to add some dependencies to the project, exactly those expressed above.
It can be done by adding the following list to the `deps` method of the `MixProject` located inside `mix.exs` file:
```elixir
[
{:extwitter, "~> 0.9.2"},
{:nadia, "~> 0.4.3"}
]
```
`mix` can be used to install the dependencies list:
```bash
$ mix deps.get
```