Giter VIP home page Giter VIP logo

tweetbot's Introduction

TweetBot

A simple Telegram Bot to Stream the tweets from any account from twitter to your telegram channel.This bot has been rewritten in rust if you still want to use the old source you can do that from checking out python branch

Guide

  1. Get Twitter API Keys and Access Keys from here
  2. Ask for Twitter elevated permissions here, click at Elevated option and fill the forms
  3. Go to @BotFather in telegram and create a Bot
  4. Open keys_sample.env and fill the API Keys and Access Keys and Chat ID where you want the bot to send messages.
  5. Rename key_sample.env to .env
  6. Install Rust by running the following command
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Run the Bot by executing:
cargo run --release

Heroku usage

Just do all the things given in the Guide except the 6th & 7th part and follow the further steps here for Heroku deployment.

  1. Create a Heroku APP
  2. Install Heroku Rust buildpack from here.
  3. Git add and commit the files in the project directory and make sure you have the Heroku CLI installed.
git add.  -f
git commit -m "Initial Commit"
git push heroku HEAD:master --force
  1. Then go to the app page in your heroku dashboard and turn on the dynos.

Sample Channel

This channel is just a sample channel that streams the tweets from the Twitter accounts which are usually regular with Manchester United football club latest news and stuff.

Just visit This Telegram Channel to check how the bot works

tweetbot's People

Contributors

dependabot-preview[bot] avatar dracarys18 avatar gabriellcosta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tweetbot's Issues

Unable to use with V2 API Basic

Elevated access option is dead...
I've paid for Basic access but still getting the following error:

Finished release [optimized] target(s) in 3m 36s
Running target/release/tweet_bot
Error: TweetError { kind: TweetError(TwitterError({"perf": "7626143928", "content-type": "application/json;charset=utf-8", "cache-control": "no-cache, no-store, max-age=0", "content-length": "360", "x-transaction-id": "78251de0182fd04b", "x-response-time": "3", "x-connection-hash": "336e5d427fab6a73d4d6eade39232fa65e71e72a235b8177f63334237e41c518", "date": "Wed, 10 May 2023 07:10:54 GMT", "server": "tsa_p"}, TwitterErrors { errors: [TwitterErrorCode { message: "You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve", code: 453 }] })), location: Location { file: "src/utils.rs", line: 6, col: 33 } }

.env and edition problems

Hello, I'm trying to run this bot on Replit platform.

Currently have 2 issues:

  1. There in no option to rename file keys_sample.env to .env. There is a limitation on that, some kind security problem. They do have, however, something called "Secrets (Environment variables)" which is apparently a more secure way to store passwords etc.
    My question here, can this bot be tweaked to work with "Secrets"?

  2. Another issue - while trying to run: cargo run --release
    I'm getting the following error:

_error: failed to parse manifest at /home/runner/TweetBot/Cargo.toml

Caused by:
failed to parse the edition key

Caused by:
supported edition values are 2015 or 2018, but 2021 is unknow._

Any idea, what can be done here?

Thank you for this bot and for your efforts.

Failing to retrieve images from Twitter

First off, thank you for the amazing bot!
Everything is in working order, however, I notice Tweets which include images are not appearing with the image in our Telegram channel.
Is there a setting to include images? One example from the Manchester United sample group below shows images working.

Thanks

image

Error: TweetError { kind: TweetError(BadStatus(403))

Hey, I have filled everything in .env file, however I can't run my TweetBot. Could you please tell me what could be the problem?

warning: function is never used: get_url_entity
--> src/utils.rs:25:14
|
25 | pub async fn get_url_entity(tweet: &Tweet) -> Option {
| ^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default

warning: function is never used: get_media_urls
--> src/utils.rs:36:14
|
36 | pub async fn get_media_urls(tweet: &Tweet) -> Option<Vec> {
| ^^^^^^^^^^^^^^

warning: associated function is never used: new
--> src/error/tweet_error.rs:22:12
|
22 | pub fn new(kind: TweetErrorKind) -> Self {
| ^^^

warning: tweet_bot (bin "tweet_bot") generated 3 warnings
Finished release [optimized] target(s) in 0.12s
Running target/release/tweet_bot
Started the stream
Error: TweetError { kind: TweetError(BadStatus(403)), location: Location { file: "src/stream/stream_impl.rs", line: 15, col: 5 } }

There is an Oauth file and secret which can be generated on twitter with a free account. This should let tweets be pulled with a free account but this authentication is not included in the .env file. Can the code be modified to accomplish this?

          There is an Oauth file and secret which can be generated on twitter with a free account. This should let tweets be pulled with a free account but this authentication is not included in the .env file. Can the code be modified to accomplish this?

Originally posted by @rumblersull in #37 (comment)

Feature request discussion

Hi,

This one worked great for me and has been useful for me. However the account I want tweets from posts a lot of junk and I want tweets with a specific keyword to be sent to my telegram channel.

How do I go about it ? I want to specify some 50 odd keywords and if the new tweet has any of those keywords, then I want that tweet to be sent to telegram, rather than every new tweet of the account.

Keys

Hi,
I am very new to python.
Environment variables in keys is a bit unclear for me as I am getting error that access token is invalid for telegram but I tried various combinations of putting either access token of telegram bot or Twitter API, but nothing is working for me.
Can you please add a few comments on the env file for how to configure that?
That would be a great help..
I know this could be a stupid question as many people are using this successfully.
Thanks in advance
Amit

Error in terminal

Sorry, probably a very novice question but I am having issues when running

warning: tweet_bot (bin "tweet_bot") generated 3 warnings
Finished release [optimized] target(s) in 0.16s
Running target/release/tweet_bot
thread 'main' panicked at 'Missing ACCOUNTS: NotPresent', src/config.rs:24:14
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

failed to import tweet_scrape as ts

hey how are u bro ?

iget this error

Traceback (most recent call last):
File "D:\Programmer - Codes\TweetBot-master\main.py", line 6, in

File "D:\Programmer - Codes\TweetBot-master\tweet_scrape.py", line 15, in
class TwitterStream(tp.StreamListener):
AttributeError: module 'tweepy' has no attribute 'StreamListener'

Access permission issue

Thank you for developing the Twitter bot, which allows me to quickly get started with such a great tool without any programming background. However, it seems that some problems have occurred during my use:

warning: `tweet_bot` (bin "tweet_bot") generated 3 warnings
    Finished release [optimized] target(s) in 5m 08s
     Running `target/release/tweet_bot`
Error: TweetError { kind: TweetError(TwitterError({"perf": "7626143928", "content-type": "application/json;charset=utf-8", "cache-control": "no-cache, no-store, max-age=0", "content-length": "311", "x-transaction-id": "3fccce770c5517c1", "x-response-time": "161", "x-connection-hash": "c35e1e9e80bfb05113707e47427cead188bfcd45", "date": "Wed, 15 Nov 2023 22:29:18 GMT", "server": "tsa_k"}, TwitterErrors { errors: [TwitterErrorCode { message: "You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product", code: 453 }] })), location: Location { file: "src/utils.rs", line: 6, col: 33 } }

I searched and it seems to be because the free Twitter API V2 I'm using doesn't have this permission. Can I use API V1 instead?

can't run TweetBot

Hi.

After command : cargo run --release I geting this error.
All fields in .env file I have correct.

maybe is miss something ?

sikor@sikor-ubu:~/TweetBot$ cargo run --release
warning: function is never used: get_url_entity
--> src/utils.rs:25:14
|
25 | pub async fn get_url_entity(tweet: &Tweet) -> Option {
| ^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default

warning: function is never used: get_media_urls
--> src/utils.rs:36:14
|
36 | pub async fn get_media_urls(tweet: &Tweet) -> Option<Vec> {
| ^^^^^^^^^^^^^^

warning: associated function is never used: new
--> src/error/tweet_error.rs:22:12
|
22 | pub fn new(kind: TweetErrorKind) -> Self {
| ^^^

warning: tweet_bot (bin "tweet_bot") generated 3 warnings
Finished release [optimized] target(s) in 0.08s
Running target/release/tweet_bot
thread 'main' panicked at 'Cannot get the TELOXIDE_TOKEN env variable', /home/sikor/.cargo/registry/src/github.com-1ecc6299db9ec823/teloxide-core-0.5.1/src/bot.rs:298:43
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Feature Request: Multi-Channel Support with Per Channel Twitter-IDs

Hi,

Was wondering if it might be possible for you to consider adding multi-channel support with your planned future rewrite?

Possible example of the configuration to outline the suggestion better:

Twitter:
  ACCESS_TOKEN: "ACCESS_TOKEN_HERE"
  ACCESS_TOKEN_SECRET: "ACCESS_TOKEN_SECRET_HERE"
  CONSUMER_KEY: "API_KEY_HERE"
  CONSUMER_SECRET: "API_KEY_SECRET_HERE"
Telegram:
 - IncludeRetweet: false
   IncludeUserReply: false
   IncludeReplyToUser: false
   custom_message: ""
   twitter_ids: ['utdreport', 'ManUnitedZone_']
   chat_id:
     - "-1002233445566"
     - "-1004455667788"
 - IncludeRetweet: true
   IncludeUserReply: true
   IncludeReplyToUser: false
   custom_message: ""
   twitter_ids: ['manutd']
   chat_id:
     - "-1004455667788"

No module named 'telegram'

After performing all the steps up to the requirements installing, when attempting to execute the bot, this error occurs:

root:~/TweetBot# python3.6 TweetBot/main.py
Traceback (most recent call last):
  File "TweetBot/main.py", line 1, in <module>
    import telegram
ModuleNotFoundError: No module named 'telegram'

This is the produced log whilst installing the requirements:
https://www.toptal.com/developers/hastebin/ikaqisetok.apache

Wish to seek your advice in resolving the issue

Problem

Problem with herokuapp:

Log:

022-07-19T16:48:10.142385+00:00 heroku[worker.1]: Starting process with command ./target/release/tweet_bot
2022-07-19T16:48:10.800592+00:00 heroku[worker.1]: State changed from starting to up
2022-07-19T16:48:10.884084+00:00 app[worker.1]: thread 'main' panicked at 'Missing ACCOUNTS: NotPresent', src/config.rs:24:14
2022-07-19T16:48:10.884099+00:00 app[worker.1]: note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
2022-07-19T16:48:11.027775+00:00 heroku[worker.1]: Process exited with status 101
2022-07-19T16:48:11.176182+00:00 heroku[worker.1]: State changed from up to crashed
2022-07-19T16:48:11.179858+00:00 heroku[worker.1]: State changed from crashed to starting
2022-07-19T16:48:11.506615+00:00 heroku[worker.1]: Starting process with command ./target/release/tweet_bot
2022-07-19T16:48:12.245036+00:00 heroku[worker.1]: State changed from starting to up
2022-07-19T16:48:12.379862+00:00 app[worker.1]: thread 'main' panicked at 'Missing ACCOUNTS: NotPresent', src/config.rs:24:14
2022-07-19T16:48:12.379881+00:00 app[worker.1]: note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
2022-07-19T16:48:12.658455+00:00 heroku[worker.1]: State changed from up to crashed
2022-07-19T16:48:12.508846+00:00 heroku[worker.1]: Process exited with status 101

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.