Skip to content

Commit

Permalink
Minor Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
New-dev0 committed May 2, 2023
1 parent f2e2c22 commit 8ca49ae
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,56 @@

# <p align="center"><a href="https://github.com/New-dev0/TgTwitterStreamer"><img src="https://github-readme-stats.vercel.app/api/pin?username=New-dev0&show_icons=true&theme=buefy&hide_border=false&repo=TgTwitterStreamer"></a></p>

#### A bot to stream realtime tweets to telegram chats with an addition of other customization options.

#### A bot to get and send tweets to specific telegram chats from desired users on twitter in real time with a bulk of additional customization options.
> It uses Telethon (Asynchronous Telegram Client library) and Tweepy Library to interact with Twitter API.
> It uses Telethon (Telegram Client library) and Tweepy to interact with Twitter
> Streaming API.
#

#
[![CodeFactor](https://www.codefactor.io/repository/github/new-dev0/tgtwitterstreamer/badge)](https://www.codefactor.io/repository/github/new-dev0/tgtwitterstreamer)
[![GitHub issues](https://img.shields.io/github/issues/New-dev0/TgTWitterstreamer?color=red)](#)
[![Open Source Love](https://badges.frapsoft.com/os/v3/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
<a align="center" href="https://www.producthunt.com/posts/tgtwitterstreamer?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-tgtwitterstreamer" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=371632&theme=neutral" alt="TgTwitterStreamer - Stream&#0032;twitter&#0032;tweets&#0032;to&#0032;telegram&#0032;groups&#0047;channels | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>

# Getting Started

- You may need to apply for Elevated Access from
[here](https://developer.twitter.com/en/portal/products/elevated) before
creating Twitter App.

* For Getting Required ENV's Refer this
[Link](https://new-dev0.github.io/tgtwitterbot) !
* All Enviroment Variables can be found in
[`env.sample`](https://github.com/New-dev0/TgTwitterStreamer/blob/main/.env.sample)
!

# Getting Started
- You may need to apply for Elevated Access from [here](https://developer.twitter.com/en/portal/products/elevated) before creating Twitter App.
* For Getting Required ENV's Refer this [Link](https://new-dev0.github.io/tgtwitterbot) !
* All Enviroment Variables can be found in [`env.sample`](https://github.com/New-dev0/TgTwitterStreamer/blob/main/.env.sample) !
- Detailed information about `ENV Vars` can be found [Here](./Guides/Vars.md).

## Deploy to Railway
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/eERa-1)

## Deploy to Heroku
- To Deploy to Heroku, follow this [Guide](./Guides/deploy-heroku.md)
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/eERa-1)

## Showcase
- Add the Channel/Group username to which you are streaming and the targeted usernames...

| Group | Twitter Users |
| ----- | ------------- |
| [@futurecodeschat](https://t.me/futurecodeschat) | `Neelabhtoons` |
- Add the Channel/Group username to which you are streaming and the targeted
usernames...

| Group | Twitter Users |
| ------------------------------------------------ | -------------------------------------- |
| [@futurecodeschat](https://t.me/futurecodeschat) | `sundarpichai, telegram, disneyplushs` |

## Contributing

- Any sort of Contributions are welcomed!

> Thanks to everyone who has starred the project, I hope you found it helpful! ❤️
## Support Chat

- Telegram Group - [@FutureCodesChat](https://t.me/FutureCodesChat)

### Donate
- [Contact me on Telegram](https://t.me/KarbonCopy) if you would like to donate me for my work!

- [Contact me on Telegram](https://t.me/KarbonCopy) if you would like to donate
me for my work!
6 changes: 4 additions & 2 deletions TgTwitterStreamer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ async def run():
if del_ids:
await Stream.delete_rules(del_ids)
if add_rule:
LOGGER.debug("Applying rule: " + rule)
LOGGER.debug(f"Applying rule: {rule}")
rules = (await Stream.add_rules(StreamRule(rule))).data
else:
rules = old_rules

Stream.rule_ids = [rule.id for rule in rules]
if rules:
Stream.rule_ids = [rule.id for rule in rules]

LOGGER.debug(f"filtering rules: {Stream.rule_ids}")

_MAX_RECONNECT = Var.MAX_RECONNECT # default: 20
Expand Down
6 changes: 3 additions & 3 deletions TgTwitterStreamer/tstreamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def on_response(self, response):

async def _on_response(self, response):
rule_ids = [rule.id for rule in response.matching_rules]
if not any((rule in self.rule_ids) for rule in rule_ids):
if self.rule_ids and not any((rule in self.rule_ids) for rule in rule_ids):
LOGGER.error(
"Unmatched Rule Identified, possibly there maybe multiple connections!"
)
Expand Down Expand Up @@ -206,7 +206,7 @@ async def _on_response(self, response):
await self._do_retweet(tweet["id"])

async def send_tweet(self, chat, text, photos, button, is_pic_alone, topic_id=None):
textmsg = text if (is_pic_alone or Var.DISABLE_BUTTON) else None
textmsg = text if (is_pic_alone or Var.DISABLE_BUTTON) else ""
MSG = None

try:
Expand Down Expand Up @@ -255,7 +255,7 @@ async def send_tweet(self, chat, text, photos, button, is_pic_alone, topic_id=No
LOGGER.exception(er)

if Var.AUTO_PIN and MSG:
single_msg = MSG if not isinstance(MSG, list) else MSG[0]
single_msg = MSG[0] if isinstance(MSG, list) else MSG
await self._pin(single_msg)

async def on_request_error(self, status_code):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
telethon>=1.24.0
aiohttp>=3.8.1
tweepy[async]>=4.10.0
python-decouple>=3.3
python-decouple>=3.3

0 comments on commit 8ca49ae

Please sign in to comment.