diff --git a/.github/archives/readme_old.md b/.github/archives/readme_old.md new file mode 100644 index 00000000..84da81db --- /dev/null +++ b/.github/archives/readme_old.md @@ -0,0 +1,186 @@ + + +

+ tgcf logo +

+ +

tgcf

+ +

+The ultimate tool to automate custom telegram message forwarding. +

+ +

+GitHub license +GitHub stars +GitHub issues +PyPI +Twitter +

+

+Code Quality +

+ + +
+ +--- +! warning ! this is the readme for version 0.2 (old version), and many information may not be true for present version. +--- +--- + +
+Live-syncer, Auto-poster, backup-bot, cloner, chat-forwarder, duplicator, ... + +Call it whatever you like! tgcf can fulfill your custom needs. + +The *key features* are: + +1. Forward messages as "forwarded" or +send a copy of the messages from source to destination chats. + + > A chat can be anything: a group, channel, person or even another bot. + +2. Supports two [modes](https://github.com/aahnik/tgcf/wiki/Past-vs-Live-modes-explained) +of operation _past_ or _live_. + + > The past mode deals with all existing messages, + > while the live mode is for upcoming ones. + +3. You may [login](https://github.com/aahnik/tgcf/wiki/Login-with-a-bot-or-user-account) +with a _bot_ or an _user_ account. + + > Telegram imposes certain + [limitations](https://github.com/aahnik/tgcf/wiki/Using-bot-accounts#limitations) + on bot accounts. + You may use an user account to perform the forwards if you wish. + +4. Perform custom manipulation on messages. + + > You can + [filter](https://github.com/aahnik/tgcf/wiki/How-to-use-filters-%3F), + [format](https://github.com/aahnik/tgcf/wiki/Format-text-before-sending-to-destination), + [replace](https://github.com/aahnik/tgcf/wiki/Text-Replacement-feature-explained), + [watermark](https://github.com/aahnik/tgcf/wiki/How-to-use--watermarking-%3F), + [ocr](https://github.com/aahnik/tgcf/wiki/You-can-do-OCR) + and do whatever else you need ! + +5. Detailed [wiki](https://github.com/aahnik/tgcf/wiki) + +Video tutorial. + > You can also [get help](#getting-help) from the community. + +6. If you are a python developer, writing +[plugins](https://github.com/aahnik/tgcf/wiki/How-to-write-a-plugin-for-tgcf-%3F) +for tgcf is like stealing candy from a baby. + > Plugins modify the message before they are sent to the destination chat. + +What are you waiting for? Star the repo and click Watch to recieve updates. + + +## Video Tutorial + +A youtube video is coming soon. [Subscribe](https://www.youtube.com/channel/UCcEbN0d8iLTB6ZWBE_IDugg) to get notified. + + + +## Installation + +- If you are an **Windows** user, who is not familiar with the command line, the +[Windows guide](https://github.com/aahnik/tgcf/wiki/Run-tgcf-on-Windows) +is for you. + +- To install tgcf on **Android** (Termux), there exists an installer script, +that allows you to install all dependencies by running just a single line command. +Read the +[guide for android](https://github.com/aahnik/tgcf/wiki/Run-on-Android-using-Termux) +to learn. + +- If you are familiar with **Docker**, you may read the +[docker guide](https://github.com/aahnik/tgcf/wiki/Install-and-run-using-docker) +for an isolated installation. + +- Otherwise for **Linux/Mac**, + you may install `tgcf` via python's package manager `pip`. + + > **Note:** Make sure you have Python 3.8 or above installed. + Go to [python.org](https://python.org) to download python. + + Open your terminal and run the following commands. + + ```shell + pip install --upgrade tgcf + ``` + + To check if the installation succeeded, run + + ```shell + tgcf --version + ``` + +## Usage + +Configuring `tgcf` is easy. You just need two files in your present directory +(from which tgcf is invoked). + +- [`.env`](https://github.com/aahnik/tgcf/wiki/Environment-Variables) +: To define your environment variables easily. + +- [`tgcf.config.yml`](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) +: An `yaml` file to configure how `tgcf` behaves. + +In your terminal, just run `tgcf live` or `tgcf past` to start `tgcf`. +It will prompt you to enter your phone no. or bot token, when you run it +for the first time. + +For more details run `tgcf --help` or [read wiki](https://github.com/aahnik/tgcf/wiki/CLI-Usage). + +## Deploy to Cloud + +Click on [this link](https://m.do.co/c/98b725055148) and get **free 100$** +on Digital Ocean. + +[![DigitalOcean Referral Badge](https://web-platforms.sfo2.digitaloceanspaces.com/WWW/Badge%203.svg)](https://www.digitalocean.com/?refcode=98b725055148&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge) + +> **NOTE** You will get nothing if you directly sign up from Digital Ocean Home Page. +> **Use the link** above, or **click on the big fat button** above to get free 100$. + +Deploying to a cloud server is an easier alternative if you cannot install +on your own machine. +Cloud servers are very reliable and great for running `tgcf` in live mode +for a long time. + +You can enjoy smooth one-click deploys to the major cloud providers. + +- [Heroku](https://github.com/aahnik/tgcf/wiki/Deploy-to-Heroku) +- [Digital Ocean](https://github.com/aahnik/tgcf/wiki/Deploy-to-Digital-Ocean) +- [Gitpod](https://github.com/aahnik/tgcf/wiki/Run-for-free-on-Gitpod") +- [Python Anywhere](https://github.com/aahnik/tgcf/wiki/Run-on-PythonAnywhere) +- [Google Cloud Run](https://github.com/aahnik/tgcf/wiki/Run-on-Google-Cloud) +- [GitHub Actions](https://github.com/aahnik/tgcf/wiki/Run-tgcf-in-past-mode-periodically) + +## Getting Help + +- First of all [read the wiki](https://github.com/aahnik/tgcf/wiki) +and [watch the videos](https://www.youtube.com/channel/UCcEbN0d8iLTB6ZWBE_IDugg) +to get started. + +- Type your question in GitHub's Search bar on the top left of this page, +and click "In this repository". +Go through the issues, discussions and wiki pages that appear in the result. +Try re-wording your query a few times before you give up. + +- If your question does not already exist, +feel free to ask your questions in the +[Discussion forum](https://github.com/aahnik/tgcf/discussions/new). +Please avoid duplicates. + +- For reporting bugs or requesting a new feature please use the [issue tracker](https://github.com/aahnik/tgcf/issues/new) +of the repo. + +## Contributing + +PRs are most welcome! Read the [contributing guidelines](/.github/CONTRIBUTING.md) +to get started. + +If you are not a developer, you may also contribute financially to +incentivise the development of any custom feature you need. diff --git a/.github/archives/tgcf_0.2_wiki/CLI-Usage.md b/.github/archives/tgcf_0.2_wiki/CLI-Usage.md new file mode 100644 index 00000000..e7bc5752 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/CLI-Usage.md @@ -0,0 +1,13 @@ +The application `tgcf` offers a minimal command-line interface to start it. Most of the configuration is done by using the [`tgcf.config.yml`](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) file. + +```shell +Arguments: + MODE:[past|live] Choose the mode in which you want to run tgcf. [env var: + TGCF_MODE;required] + + +Options: + -l, --loud Increase output verbosity. [env var: LOUD] + -v, --version Show version and exit. + --help Show this message and exit. +``` \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/Deploy-to-Digital-Ocean.md b/.github/archives/tgcf_0.2_wiki/Deploy-to-Digital-Ocean.md new file mode 100644 index 00000000..a363546a --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Deploy-to-Digital-Ocean.md @@ -0,0 +1,40 @@ +DigitalOcean infrastructure is a leading cloud service provider based in the United States of America. Their headquarter operates from New York City, and their data centers are prevalent in every corner of the world in order to provide seamless cloud services across the globe. + + +## App Platform + + +![create-app](https://user-images.githubusercontent.com/66209958/113475188-aab3a200-9491-11eb-8649-9c4111d05a1b.png) + +Click **Create** -> *Apps* + + +![source-is-docker-hub](https://user-images.githubusercontent.com/66209958/113475207-c1f28f80-9491-11eb-84d1-5b90e6a4ee3c.png) + +Choose **Docker Hub** as the source. +Choose the **type** as _"Worker"_ (as we are not making any web app). + +In the next step,the **repository** path is _"aahnik/tgcf"_. + +![type-worker](https://user-images.githubusercontent.com/66209958/113475243-fbc39600-9491-11eb-9c2e-96fb0487d43d.png) + +You can now set the values of the [environment variables](https://github.com/aahnik/tgcf/wiki/Environment-Variables) from this beautiful interface provided by Digital Ocean. + + +Give any name to your app. After this, you will be lead to a pricing page. Choose a pricing plan suitable for you and click "Launch basic app". + + + +## Ubuntu Droplet + +If you want more control, you may run `tgcf` on a VPS like DigitalOcean's ubuntu droplets. + +Steps: +- Create a Droplet +- SSH into it +- Update packages +- Install python +- Install `tgcf` +- Use `tgcf` CLI + +Details coming soon! \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/Deploy-to-Heroku.md b/.github/archives/tgcf_0.2_wiki/Deploy-to-Heroku.md new file mode 100644 index 00000000..febe00cd --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Deploy-to-Heroku.md @@ -0,0 +1,50 @@ +Heroku is a cloud platform that lets companies build, deliver, monitor, and scale apps, it is one of the fastest ways to go from idea to URL, bypassing all those infrastructure headaches. + +You can deploy `tgcf` to Heroku very easily. + +## Limitations + +- Heroku has an ephemeral file system. +- Thus you cant store your files here. +- `tgcf.config.yml` can't be created here. +- Instead, you can use an environment variable named `TGCF_CONFIG` to store the contents of the configuration file. +- `tgcf` in past mode won't work properly in Heroku, as the environment variable TGCF_CONFIG can't be updated. + +## Pros + +- `tgcf` will work **perfectly fine** in `live` mode in Heroku. +- Heroku offers a great free tier of 450 hrs/mo + +## One-click deploy + +1. Make sure you have a Heroku account and then click on this button. + + Deploy to Heroku + +2. A Heroku page will open where you can set all the environment variables. + +- Set the name of the app whatever you want. + + ![image](https://user-images.githubusercontent.com/66209958/115880520-7287f980-a468-11eb-9bfc-5a72cbe668d9.png) + +- Set your API ID and API HASH obtained from [my.telegram.org](https://my.telegram.org). Set the mode to `live`. + + +- You may keep your `SESSION_STRING` and `TGCF_CONFIG` empty for now. + + +- Now click the deploy app button. + + +3. It will take some time to build and deploy. After the deployment is complete, click on the manage app button. + ![image](https://user-images.githubusercontent.com/66209958/115881849-cb0bc680-a469-11eb-8b35-6bf5c6a5eca4.png) + +4. How to get the session string? [Read this](https://github.com/aahnik/tgcf/wiki/Login-with-a-bot-or-user-account#generate-session-string). + +5. Now go to the settings tab and click Reveal config vars. Click on the pencil button for the session string and config var, and then paste the session string the value of that. + +6. Learn [how to configure tgcf](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F), and then write your configuration in the `TGCF_CONFIG` env var. + +7. Go to the resources tab, and turn on the worker and click confirm. + +![image](https://user-images.githubusercontent.com/66209958/115882913-dc090780-a46a-11eb-980b-6b0f49ff45f5.png) \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/Environment-Variables.md b/.github/archives/tgcf_0.2_wiki/Environment-Variables.md new file mode 100644 index 00000000..2f0872ef --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Environment-Variables.md @@ -0,0 +1,37 @@ +An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs. + +The secret credentials like `API_ID` and `API_HASH` are stored as environment variables. + +## All env vars + +| Env Var | Value | Requirement | +| ---------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| **`API_ID`** | obtain it from [my.telegram.org](https://my.telegram.org) | always required | +| **`API_HASH`** | obtain it from [my.telegram.org](https://my.telegram.org) | always required | +| `TGCF_MODE` | [`past` or `live`](https://github.com/aahnik/tgcf/wiki/Past-vs-Live-modes-explained) | only required if you don't have interactive shell while running `tgcf`. | +| `BOT_TOKEN` | obtained from [@BotFather](https://telegram.me/BotFather) | required if you are running`tgcf`with a bot account. | +| `SESSION_STRING` | obtained after [login](https://github.com/aahnik/tgcf/wiki/Login-with-a-bot-or-user-account#generate-session-string) | only required if you are using `tgcf`with user account. | +| `TGCF_CONFIG` | contents of [`tgcf.config.yml`](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) | only required if you cant edit files in your cloud deploy (digital ocean app or heroku dyno) | + + + + +## Setting env vars + +There are various methods to set env vars + +### `.env` File + +You can easily set environment variables for `tgcf` using a `.env` file in the directory from which `tgcf` is invoked. + +```shell +API_ID=543213 +API_HASH=uihfuiwruiw28490238huawfiuhf +# put your real values here +``` + +### Cloud Deploys + +When you are deploying to a cloud platform, and you cant create files (Heroku or digital ocean apps), you can set environment variables using the GUI provided by the platforms. Please read platform-specific guides in the wiki for more details. + +When you are deploying on a cloud platform, you can configure tgcf using environment variables. The contents of `tgcf.config.yml` can be put inside the environment variable called `TGCF_CONFIG`. \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/Flood-wait-errors-and-bans.md b/.github/archives/tgcf_0.2_wiki/Flood-wait-errors-and-bans.md new file mode 100644 index 00000000..1cbe0468 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Flood-wait-errors-and-bans.md @@ -0,0 +1,6 @@ +Flood wait errors are imposed by telegram. Telegram has a rate limit of how many messages you can send. + +When a flood wait error occurs, tgcf waits for the required time and then resumes. + +More info to be added soon! + diff --git a/.github/archives/tgcf_0.2_wiki/Format-text-before-sending-to-destination.md b/.github/archives/tgcf_0.2_wiki/Format-text-before-sending-to-destination.md new file mode 100644 index 00000000..4d235141 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Format-text-before-sending-to-destination.md @@ -0,0 +1,17 @@ +The `format` plugin allows you to force a style before sending the messages to destination chat. + +Make sure you have read +- [How to configure tgcf](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) +- [Plugins](https://github.com/aahnik/tgcf/wiki/Plugins) + + +To use the `format` plugin, put the following in your configuration file. + +```yaml +plugins: + # ... your other plugins here + format: + style: bold # choose from [ bold, italics, code, strike, plain, preserve ] + # ... other plugins + +``` \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/Home.md b/.github/archives/tgcf_0.2_wiki/Home.md new file mode 100644 index 00000000..84467285 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Home.md @@ -0,0 +1,62 @@ +Welcome to the tgcf wiki! + +| [Overview](https://github.com/aahnik/tgcf#readme) | [Roadmap](https://github.com/aahnik/tgcf/discussions/43) | [Support](https://github.com/aahnik/tgcf/discussions/2) | [FAQs](https://github.com/aahnik/tgcf/discussions/196) | +| -------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------ | + + +
+Platforms +
+ +- [Run tgcf on Windows](https://github.com/aahnik/tgcf/wiki/Run-tgcf-on-Windows) +- [Run on Android using Termux](https://github.com/aahnik/tgcf/wiki/Run-on-Android-using-Termux) +- [Install and run using docker](https://github.com/aahnik/tgcf/wiki/Install-and-run-using-docker) + +
+ +
+Basics +
+ +- [Past vs Live modes explained](https://github.com/aahnik/tgcf/wiki/Past-vs-Live-modes-explained) +- [Environment Variables](https://github.com/aahnik/tgcf/wiki/Environment-Variables) +- [How to configure tgcf ?](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) +- [CLI Usage](https://github.com/aahnik/tgcf/wiki/CLI-Usage) +- [Running continuously in background](https://github.com/aahnik/tgcf/discussions/219#discussioncomment-920558) + +
+ +
+Deploy to cloud +
+ +- [Deploy to Heroku](https://github.com/aahnik/tgcf/wiki/Deploy-to-Heroku) +- [Deploy to Digital Ocean](https://github.com/aahnik/tgcf/wiki/Deploy-to-Digital-Ocean) +- [Run for free on Gitpod](https://github.com/aahnik/tgcf/wiki/Run-for-free-on-Gitpod) +- [Run tgcf in past mode periodically using GitHub Actions](https://github.com/aahnik/tgcf/wiki/Run-tgcf-in-past-mode-periodically) + +
+ +
+Plugins +
+ +- [Intro](https://github.com/aahnik/tgcf/wiki/Plugins) +- [How to use filters ?](https://github.com/aahnik/tgcf/wiki/How-to-use-filters-%3F) +- [Format text before sending to destination](https://github.com/aahnik/tgcf/wiki/Format-text-before-sending-to-destination) +- [Text Replacement feature explained](https://github.com/aahnik/tgcf/wiki/Text-Replacement-feature-explained) +- [How to use watermarking ?](https://github.com/aahnik/tgcf/wiki/How-to-use--watermarking-%3F) +- [You can do OCR !](https://github.com/aahnik/tgcf/wiki/You-can-do-OCR) + +
+ + +
+Development +
+ +- [How to write a plugin for tgcf ?](https://github.com/aahnik/tgcf/wiki/How-to-write-a-plugin-for-tgcf-%3F) +- [Contributing Guidelines](https://github.com/aahnik/tgcf/blob/main/.github/CONTRIBUTING.md#contributing-guidelines) +- [Package management with Poetry](https://python-poetry.org/docs/) +- [Telethon documentation](https://docs.telethon.dev/en/latest/) +
\ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/How-to-configure-tgcf-?.md b/.github/archives/tgcf_0.2_wiki/How-to-configure-tgcf-?.md new file mode 100644 index 00000000..46bfc7c1 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/How-to-configure-tgcf-?.md @@ -0,0 +1,66 @@ +The application `tgcf` is configured using a simple `YAML` file. If you are new to the `YAML` syntax, don't worry, it's easy, and you will learn it. + +## Introducing YAML + +Tutorials on YAML syntax: +- [Article by Tutorial Point](https://www.tutorialspoint.com/yaml/yaml_basics.htm) +- [Article by W3 Schools](https://www.w3schools.io/file/yaml-cheatsheet-syntax) +- [YouTube video by Nana](https://youtu.be/1uFVr15xDGg?t=73) + +## Where to write + +You may write your configuration in the `tgcf.config.yml` file. (when running on your own computer) + +When you are deploying on a cloud platform where you can't edit files, you may configure tgcf using environment variables. The contents of `tgcf.config.yml` can be put inside the environment variable called `TGCF_CONFIG`. Read the wiki for platform-specific guides on how to set environment variables in different platforms. + + +## Example Configuration + +- For the `source` and `dest` fields use the username of the channel/bot/person/group. (omit the `@` symbol at the start). +- If the private entity does not have a username, you may use the link of the private channel/group. + +Below is an example configuration. Don't copy-paste this. Understand what each part does. + +```yaml +admins: [yourUserName,AnotherPerson] +# when tgcf is run in live mode, the admins can run commands to change the configuration + +forwards: + - source: channelName + dest: [anotherChannel,https://t.me/channelLink] + # use username or link of the entity + + +show_forwarded_from: false + +plugins: + filter: + text: + blacklist: ["nope"] + replace: + text: + god: devil + tokyo: delhi + +``` + +## Schema + +Here is the complete schema for the configuration file. + +- `admins` (the list of usernames or ids of the admins) + > - setting admins is not compulsory + > - if no admins are set, and you run tgcf in live mode, then no one can run commands to change the configuration. + > - the bot/user bot **will work perfectly fine** as per your configuration file +- `forwards` (a list of forward objects) + - forward ( contains a `source` (string), a `dest` (list of strings) and an `offset`(optional integer) ) +- `show_forwarded_from` (boolean: true/false) +- `live` + - `delete_sync` : bool (true or false) +- `past` + - `delay`: int (between 1 to 100 )(seconds) (time to wait after every message is sent) + + +- `plugins` contain the name of the plugin and the data to be passed to that plugin. + - What data to pass to plugins? is defined in the documentation for that plugin. Here is the [list of all plugins](https://github.com/aahnik/tgcf/wiki/Plugins). + diff --git a/.github/archives/tgcf_0.2_wiki/How-to-use--watermarking-?.md b/.github/archives/tgcf_0.2_wiki/How-to-use--watermarking-?.md new file mode 100644 index 00000000..922d4b2d --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/How-to-use--watermarking-?.md @@ -0,0 +1,21 @@ +Make sure you have read +- [How to configure tgcf](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) +- [Plugins](https://github.com/aahnik/tgcf/wiki/Plugins) + +The `mark` plugin allows you to apply a watermark on images/videos/gifs. + +If an image/video/gif is posted in the source chat, the watermarked version will be sent to the destination chat. + +Just put this in your configuration file. + +```yaml +plugins: + # ... your other plugins here + mark: + image: /path/to/image.png # the image to apply as watermark + # this can be a local path, or an URL starting with https:// +``` + +If you are running on your own computer,you must have [ffmpeg](https://ffmpeg.org/) installed in your system for this. + +If you are deploying to cloud platform, or running tgcf using the Docker method as per the instructions in the wiki, then there is nothing to worry. \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/How-to-use-filters-?.md b/.github/archives/tgcf_0.2_wiki/How-to-use-filters-?.md new file mode 100644 index 00000000..95dc6089 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/How-to-use-filters-?.md @@ -0,0 +1,36 @@ +Filters allow you to selectively forward some messages while excluding others. + + + +For an intro to configuration [read this](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) page. + +## Example + +```yaml +plugins: + filter: + + text: + case_sensitive: true # default is false if you don't write this line + # the case_sensitive param has no significance if regex is set to true + whitelist: ["this word"] + blacklist: ["hello"] + regex: false # default is false. + # set to true if you want the expressions in whitelist and blacklist + # to be evaluated as regular expressions + + users: + blacklist: [1547315064] # currently user ids are supported only. + # get user ids from @userinfobot on telegram + + files: + whitelist: [document,nofile] + # valid types are + # audio,gif,video,video_note,sticker,contact,photo,document,nofile + + +``` + +Note: +- for text filtering, you may use whitelist or blacklist or both +- for users and files filtering, use either a whitelist or a blacklist diff --git a/.github/archives/tgcf_0.2_wiki/How-to-write-a-plugin-for-tgcf-?.md b/.github/archives/tgcf_0.2_wiki/How-to-write-a-plugin-for-tgcf-?.md new file mode 100644 index 00000000..fa72717d --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/How-to-write-a-plugin-for-tgcf-?.md @@ -0,0 +1,51 @@ +### [WARNING] ❗this document is not up-to-date with the latest changes of tgcf. Please re-visit after a few days. + +
+
+
+
+ + +This tutorial is for python developers. If you are a general user, you may make a feature request for a plugin you need. + +## Prerequisites +- Intermediate level knowledge of [Python](https://python.org) programming language +- Basic knowledge of [Telethon](https://github.com/LonamiWebs/Telethon) +- Some idea about how `tgcf` works + + +Writing a plugin is a piece of cake. A plugin is basically a python module that can be imported by `tgcf`. You can even package it and publish it to PyPI for providing an easy `pip install` for your users. + +## Naming Rules + +The plugin name (also known as plugin id) should be a single word in lowercase describing the feature. + +For example: if your plugin name is `hello`, then the name of the package should be `tgcf_hello`, and the name of the plugin class should be `TgcfHello`. + +## Write your first plugin + +First of all, create a folder named `tgcf_hello`, and inside it create `__init__.py`. For the sake of simplicity, in this example, we will be writing our logic inside `__init__.py`. For complex plugins, you can have multiple modules and even sub-packages. + + +```python +# __init__.py + + +class TgcfHello: + id = "hello" + # the plugin class must have this `id` attribute + + def __init__(self, data): + # the plugin class must have a constructor and should validate data here + self.data = data + + def modify(self, message): + # the modify method, receives the message collected by tgcf + # the output of this method will be forwarded + + # manipulate the message here + return message + +``` + +More details to be added soon! diff --git a/.github/archives/tgcf_0.2_wiki/Install-and-run-using-docker.md b/.github/archives/tgcf_0.2_wiki/Install-and-run-using-docker.md new file mode 100644 index 00000000..e81c8b93 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Install-and-run-using-docker.md @@ -0,0 +1,57 @@ +It is assumed that you are familiar with basic `docker` commands. Docker should be properly installed and running in your system. + + +- Make sure you have understood how `tgcf` is run by passing certain variables via [command-line options](https://github.com/aahnik/tgcf/wiki/CLI-usage) or by setting them as [environment variables](https://github.com/aahnik/tgcf/wiki/Environment-Variables). +- Read about [`tgcf.config.yml`](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) to know how you can configure `tgcf` + +## Install + + +Pull the [official docker image](https://hub.docker.com/r/aahnik/tgcf) from DockerHub. + +```shell +docker pull aahnik/tgcf +``` + +> **Tip**: Use `aahnik/tgcf:minimal` for a smaller image size. (beta) + +## Configure + +- Write all your [environment variables](https://github.com/aahnik/tgcf/wiki/Environment-Variables#create-a-env-file) in a file called `.env`. +- Write your [configuration](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) + in `tgcf.config.yml`. + +## Run + +```shell +docker run -v absolute/path/to/tgcf.config.yml:/app/tgcf.config.yml -d --env-file .env aahnik/tgcf +``` + +Note: +- the `-d` flag tells the docker command to run the container in detached mode. +- the `--env-file` option passes the file `.env` for its variables to be used inside the container. + + +## Check + +To see if your container is running, + +```shell +$ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +ae4d7d6651ca aahnik/tgcf "tgcf --loud" 3 minutes ago Up 3 minutes zen_gates + +``` + +The container id and name will be different in your machine. + +To see the logs produced by the container, + +```shell +$ docker logs zen_gates +``` + +Replace `zen_gates` with the name of the container in your machine. + + + diff --git a/.github/archives/tgcf_0.2_wiki/Install-from-source.md b/.github/archives/tgcf_0.2_wiki/Install-from-source.md new file mode 100644 index 00000000..373ce6c8 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Install-from-source.md @@ -0,0 +1,44 @@ +Warning: This method of installation of `tgcf` is only for python developers, and not recommended for normal users. + +## Requirements + +| Thing | Why | +| -------------------------------------------- | ------------------------------------------------------ | +| [`git `](https://git-scm.com/) | to clone the repo and for version control | +| [`python`](https://www.python.org/) | language tgcf is written | +| [`poetry`](https://python-poetry.org/) | used for package management | +| [`docker`](https://www.docker.com/) | if you want to build docker images or run using docker | +| [`make`](https://www.gnu.org/software/make/) | if you are interested in developing | + + + + +## Steps + +1. Clone the repo and move into it + ```shell + git clone https://github.com/aahnik/tgcf.git && cd tgcf + ``` + +2. Install dependencies with `poetry` + ```shell + poetry install + ``` + > Don't have poetry? Run `pip install pipx` and then `pipx install poetry`. To add poetry to path, run `pipx ensurepath` + +3. Activate the virtual environment + ```shell + + poetry shell + ``` + +4. Now the `tgcf` command is available to you. + ```shell + tgcf --help + ``` + +5. To fetch updates from GitHub + ```shell + git fetch && git pull + ``` + Now, go back to step 2 to install the updates. diff --git a/.github/archives/tgcf_0.2_wiki/Login-with-a-bot-or-user-account.md b/.github/archives/tgcf_0.2_wiki/Login-with-a-bot-or-user-account.md new file mode 100644 index 00000000..bd918748 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Login-with-a-bot-or-user-account.md @@ -0,0 +1,48 @@ + +In Telegram, there are two types of accounts: Users and Bots. With `tgcf` you may use your own user account or a bot that you have created. + +
+ Read this if you are planning to use a bot account +
+ +- You can create a bot from [@BotFather](https://telegram.me/BotFather) +- The bot must be added to the groups and channels (both source and destination) +- The privacy mode of bots should be set to off. That means the bot should be allowed to listen to all messages in the channels/groups it is a member of. By default this setting is `on`, you have to turn privacy mode `off` from BotFather. + +
+ +## Default behavior + +When you run `tgcf` for the first time, it will interactively prompt you to enter your phone number or bot token. A session file will be generated and saved in the folder from which you ran `tgcf`. + +When you will run `tgcf` again, from the same folder, you will not be required to log in. + +## Generate Session String + + +### Run Online + +Click on the below button to run in a free repl. + +[![run on repl](https://docs.replit.com/images/repls/run-on-replit.svg)](https://replit.com/@aahnik/tg-login) + +- The session string will not be printed on the screen. (for security purposes) +- The session string will be securely saved in your Saved Messages (if you log in with your own user account). +- The session string will be sent to you (if you log in with a bot account). +- All sensitive user input in the repl is made invisible to ensure high security. + +### Run on your machine + +- Open your terminal in Mac/Windows/Linux/Android +- Make sure you have `python` installed. + If you don't have python: + - for Linux/Mac, its generally already installed. + - for windows install python 3.8 or above from the Microsoft store + - for android (termux) run `pkg install python` + +- Install `tg-login` by running `pip install tg-login` +- Run `tg-login` +- It will prompt you to enter your details, and then print your session string on the screen. +- Copy the session string, and never share it with anyone. + + diff --git a/.github/archives/tgcf_0.2_wiki/Past-vs-Live-modes-explained.md b/.github/archives/tgcf_0.2_wiki/Past-vs-Live-modes-explained.md new file mode 100644 index 00000000..7e020f09 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Past-vs-Live-modes-explained.md @@ -0,0 +1,6 @@ +| | past | live | +| -------- | ------------------------------------------------------------ | ------------------------------------------------------- | +| *what* | forwards all existing messages from source to destination | instantly forwards new message in source to destination | +| *usage* | make a clone or backup free books/movies channels | live syncing of channel content | +| accounts | only user account is supported for past mode ([why?](https://github.com/aahnik/tgcf/discussions/126)) | both user and bot accounts supported for live mode | + diff --git a/.github/archives/tgcf_0.2_wiki/Plugins.md b/.github/archives/tgcf_0.2_wiki/Plugins.md new file mode 100644 index 00000000..6068e54e --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Plugins.md @@ -0,0 +1,21 @@ + +## Official Plugins + +The official plugins are installed by default when you install `tgcf`. The source code of these plugins lies under the [`plugins` ](https://github.com/aahnik/tgcf/tree/main/tgcf/plugins) subpackage of `tgcf`. + +Some of the plugins may have additional non-python dependencies, which you need to manually install. Click on the link to the plugin to learn how to use it. + +1. [Filter](https://github.com/aahnik/tgcf/wiki/How-to-use-filters-%3F) +2. [Replace](https://github.com/aahnik/tgcf/wiki/Text-Replacement-feature-explained) +3. [Format](https://github.com/aahnik/tgcf/wiki/Format-text-before-sending-to-destination) +4. [Watermark](https://github.com/aahnik/tgcf/wiki/How-to-use--watermarking-%3F) +5. [OCR](https://github.com/aahnik/tgcf/wiki/You-can-do-OCR) + +More plugins coming soon! + +## Third-Party Plugins + +Third-party plugins are those which are developed by other developers. They live in their own repositories. If you have built a `tgcf` plugin, then you can list them here. Just send me a message on [Telegram](https://telegram.me/aahnikdaw). + +Read the tutorial [How to write a plugin for `tgcf`](https://github.com/aahnik/tgcf/wiki/How-to-write-a-plugin-for-tgcf-%3F) for more information. + diff --git a/.github/archives/tgcf_0.2_wiki/Run-for-free-on-Gitpod.md b/.github/archives/tgcf_0.2_wiki/Run-for-free-on-Gitpod.md new file mode 100644 index 00000000..0e9cb7c1 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Run-for-free-on-Gitpod.md @@ -0,0 +1,23 @@ +Gitpod is a cloud IDE used for rapid development. + +If you are planning to use `tgcf`, then one way is to install it on your computer. The other way is to run it in a cloud environment. Gitpod is the easiest way to go. + +1. Click this button, to open a fresh workspace in Gitpod + + Run on Gitpod + + +2. Don't worry about the huge no. of source code files in the IDE. If you are not a developer, then leave them alone. + + +3. `tgcf` is ready to use. + ```shell + tgcf --help + # prints the CLI usage + ``` + +4. Create two new files [`.env`](https://github.com/aahnik/tgcf/wiki/Environment-Variables) and [`tgcf.config.yml`](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) and fill them up. + + + diff --git a/.github/archives/tgcf_0.2_wiki/Run-on-Android-using-Termux.md b/.github/archives/tgcf_0.2_wiki/Run-on-Android-using-Termux.md new file mode 100644 index 00000000..e25f6551 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Run-on-Android-using-Termux.md @@ -0,0 +1,51 @@ +Hopefully, you have already read the README for a basic introduction to `tgcf`. + +The Termux app in Android offers you a full-blown Linux terminal. + +[![image](https://user-images.githubusercontent.com/66209958/115503616-559acd00-a294-11eb-8909-a27ff9a6efd6.png)](https://play.google.com/store/apps/details?id=com.termux&hl=en&gl=US) + +Install [Termux](https://play.google.com/store/apps/details?id=com.termux&hl=en&gl=US) from Google Play Store. + +> **Note:** Termux does not work well with Android 5 or 6. Don't worry! Most probably you have a much newer version of Android. + +## Install `tgcf` on termux + +Just open your termux and run this: + +```shell +curl -Lks bit.ly/tgcf-termux | bash +``` + +
+ What happens when you run the above line? +
+ +- The above line (the installation command) actually fetches the installer script and runs it using bash. +- Read the installer script by visiting the link [bit.ly/tgcf-termux](http://bit.ly/tgcf-termux). You may execute the lines one by one, manually. + +
+ + + +## Testing + +To test if `tgcf` was properly installed, + +```shell +tgcf --version +``` + +It should output version no. and that should match with the version of the [latest release](https://github.com/aahnik/tgcf/releases). + +## Configure and run + +Learn about + - [environment variables](https://github.com/aahnik/tgcf/wiki/Environment-Variables), + - [CLI usage](https://github.com/aahnik/tgcf/wiki/CLI-Usage) and + - how to [configure tgcf](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F), + and then start using `tgcf`. + +When you install `tgcf` using the above method, the text editor `micro` is also installed. You can use `micro` to edit text files. + + + diff --git a/.github/archives/tgcf_0.2_wiki/Run-on-Google-Cloud.md b/.github/archives/tgcf_0.2_wiki/Run-on-Google-Cloud.md new file mode 100644 index 00000000..2b8bdc65 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Run-on-Google-Cloud.md @@ -0,0 +1 @@ +coming soon ... \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/Run-on-PythonAnywhere.md b/.github/archives/tgcf_0.2_wiki/Run-on-PythonAnywhere.md new file mode 100644 index 00000000..74d27a78 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Run-on-PythonAnywhere.md @@ -0,0 +1 @@ +coming soon... \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/Run-tgcf-in-past-mode-periodically.md b/.github/archives/tgcf_0.2_wiki/Run-tgcf-in-past-mode-periodically.md new file mode 100644 index 00000000..f2f390e6 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Run-tgcf-in-past-mode-periodically.md @@ -0,0 +1,41 @@ +You can set up cron jobs! + +for free using GitHub Actions scheduled workflows. + +Or, you may even trigger the workflow manually! + +How to do ? + +Step1. Go to https://github.com/aahnik/tgcf-on-gh-action + +Step2. Click on the "use this template" button + +![image](https://user-images.githubusercontent.com/66209958/117601342-b880d500-b16b-11eb-91a2-2f1bf1ccec6a.png) + +Step3. Give any interesting name to your repo, and make it public (unlimited free) or private (limited to action minutes per month). + +![image](https://user-images.githubusercontent.com/66209958/117601415-f251db80-b16b-11eb-85ca-24ebc28ec3f5.png) + +If your repo is public, only your configuration file will be visible to others. Your secrets such as API_ID, API_HASH,SESSION_STRING, are stored safe in github secrets. + +Step4. Go to settings -> secrets of the repo + +Create the following secrets + +1. API_ID +2. API_HASH +3. SESSION_STRING (get it from [here](https://github.com/aahnik/tgcf/wiki/Login-with-a-bot-or-user-account#generate-session-string) ) + +![image](https://user-images.githubusercontent.com/66209958/117601591-62f8f800-b16c-11eb-8b9f-a45d69afca2c.png) + +Step5. Edit the `tgcf.config.yml` file according to your needs, + + +Step6. Go to the Actions tab -> Select tgcf-past -> Run workflow + +![image](https://user-images.githubusercontent.com/66209958/117601708-a0f61c00-b16c-11eb-9f2b-c525b24a4064.png) + +To run periodically, set a schedule for `on` param in your workflow file + +for cron syntax use https://crontab.guru/ or https://cron.help/ + diff --git a/.github/archives/tgcf_0.2_wiki/Run-tgcf-on-Windows.md b/.github/archives/tgcf_0.2_wiki/Run-tgcf-on-Windows.md new file mode 100644 index 00000000..1a9816a6 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Run-tgcf-on-Windows.md @@ -0,0 +1,53 @@ +Windows is a mess! In Linux or Mac, a terminal and python are generally pre-installed. But that's not the case with windows. + +Here goes the complete guide to set up and use `tgcf` on a Windows machine. + +## Pre-requisites + +1. Open Microsoft Store + + ![image](https://user-images.githubusercontent.com/66209958/115837680-7a2eaa80-a436-11eb-9cca-11e12694e8b3.png) + +2. Install [Powershell]() , [Windows Terminal](), and Python 3.9 + + + ![image](https://user-images.githubusercontent.com/66209958/115838965-d0e8b400-a437-11eb-818a-652951ae44ee.png) + + ![image](https://user-images.githubusercontent.com/66209958/115839446-49e80b80-a438-11eb-9149-b93d6218e0dc.png) + + ![image](https://user-images.githubusercontent.com/66209958/115839540-608e6280-a438-11eb-91e6-9285cc6301ee.png) + + + ![image](https://user-images.githubusercontent.com/66209958/115959754-644ee180-a52b-11eb-8ff7-a55692beb853.png) + +3. By default windows has Notepad. Its a horrible text editor. Windows file explorer is also shitty. It appends `.txt` to every text file. For a better experience, Install VS Code from [code.visualstudio.com](https://code.visualstudio.com/) for easy editing of text files. +When you will be writing the `tgcf.config.yml` VS code will automatically provide syntax highlighting and type checking. + ![Screenshot (7)](https://user-images.githubusercontent.com/66209958/115840953-e4951a00-a439-11eb-9db4-b87733e2dd98.png) + +## Install tgcf + + Open Powershell in Windows Terminal and run pip install tgcf + + ![image](https://user-images.githubusercontent.com/66209958/115841408-6127f880-a43a-11eb-92fd-215ab3a4c8aa.png) + + +## Configure and Run + +1. You should create a new folder to store `tgcf` configuration files. Every time you run `tgcf` you should run from inside this folder. + +2. Open the folder with VS Code and create the files `.env` and `config.tgcf.yml`. +You will be required to login to your Telegram account only for the first time. The session files will be stored in this folder. Don't delete them, and keep them secret. +, go inside it, create .env and tgcf.config.yml, run tgcf +![Screenshot (12)](https://user-images.githubusercontent.com/66209958/115847554-b5ce7200-a440-11eb-93e0-55de40a611e5.png) +![Screenshot (13)](https://user-images.githubusercontent.com/66209958/115847567-b8c96280-a440-11eb-8540-34dd89c273c9.png) +![Screenshot (14)](https://user-images.githubusercontent.com/66209958/115847578-bbc45300-a440-11eb-8dff-6e9f163885ba.png) +![Screenshot (15)](https://user-images.githubusercontent.com/66209958/115847590-be26ad00-a440-11eb-9879-b78cabef0d2d.png) +![Screenshot (17)](https://user-images.githubusercontent.com/66209958/115847693-d5659a80-a440-11eb-9e3e-fcdff16c3c97.png) + +3. Open terminal in VS Code and run tgcf + +![Screenshot (19)](https://user-images.githubusercontent.com/66209958/115848550-9f74e600-a441-11eb-92bb-ee014a9639c7.png) +![Screenshot (20)](https://user-images.githubusercontent.com/66209958/115848561-a1d74000-a441-11eb-87c7-731be1bcbca9.png) + +Every time, run tgcf from the same folder. + diff --git a/.github/archives/tgcf_0.2_wiki/Text-Replacement-feature-explained.md b/.github/archives/tgcf_0.2_wiki/Text-Replacement-feature-explained.md new file mode 100644 index 00000000..17a92746 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Text-Replacement-feature-explained.md @@ -0,0 +1,38 @@ +For an intro to configuration [read this](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) page. + +## Simple Replacement + +Inside your configuration under the plugins section put this: + +```yaml +plugins: + replace: + text: + "god": devil + "smart": idiot + "original": new +``` + +In the above example, "god" will be replaced by "devil" and "smart" will be replaced by "idiot" and so on. + +## Using Regex + +If you want to use regex, you can do so, by setting `regex: true`. + +Example: + +```yaml +plugins: + replace: + text: + "regex pattern": "new word" + + regex: true +``` + + + + + + + diff --git a/.github/archives/tgcf_0.2_wiki/Using-bot-accounts.md b/.github/archives/tgcf_0.2_wiki/Using-bot-accounts.md new file mode 100644 index 00000000..54d29f28 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Using-bot-accounts.md @@ -0,0 +1,7 @@ + +## Limitations + +These are the limitations for using bot accounts. + +- Bots can't read or send messages to other bots. +- Bots can get the history of a chat. So you cant run tgcf in past mode with a bot account. diff --git a/.github/archives/tgcf_0.2_wiki/Using-with-systemctl.md b/.github/archives/tgcf_0.2_wiki/Using-with-systemctl.md new file mode 100644 index 00000000..fa59c204 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/Using-with-systemctl.md @@ -0,0 +1,90 @@ +For more info about running tgcf in the background [read this discussion ➥](https://github.com/aahnik/tgcf/discussions/219) + +## Create a service + +Step by step guide + +**Step 1.** +Create an **executable shell script** to start tgcf from the proper folder. Let's name it `tgcf_start.sh` and put it in your home folder. + +```shell +#!/usr/bin/bash + +cd /home/aahnik/Desktop/tgcf # the folder in which tgcf is cloned +# dont use ~ in the path, use full expanded absolute path +# the folder must contain the proper .env and tgcf.config.yml files + +# tgcf must be installed inside a virtual env (recommended) +# install tgcf using pip or clone the repo and run poetry install + +.venv/bin/tgcf live --loud +``` + +Make the script executable. + +```shell +chmod +x tgcf_start.sh +``` + +**Step 2.** +Create a service. + +Create a file named `tgcf.service` and put the following content into it. + +```ini +[Unit] +Description=The ultimate tool to automate custom telegram message forwarding. +After=network.target + +[Install] +WantedBy=multi-user.target + +[Service] +Type=simple +ExecStart=/home/aahnik/tgcf_start.sh +# use the absolute path of the shell script in your server +Restart=always +RestartSec=5 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=%n + +``` + +**Step 3.** +Install and enable the service. + +```shell +sudo mv tgcf.service /etc/systemd/system +sudo systemctl daemon-reload +sudo systemctl enable tgcf.service +``` + + +## Running via `systemctl` + +Now to **start tgcf** using systemctl you can simply do + +```shell +sudo systemctl start tgcf +``` + +You can also **see the status** of the service by running + +```shell +sudo systemctl status tgcf +``` + +To **see the live logs** + +```shell +journalctl -f -u tgcf +``` + +To **stop the service** + +```shell +sudo systemctl stop tgcf +``` + + diff --git a/.github/archives/tgcf_0.2_wiki/You-can-do-OCR.md b/.github/archives/tgcf_0.2_wiki/You-can-do-OCR.md new file mode 100644 index 00000000..300d7bf8 --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/You-can-do-OCR.md @@ -0,0 +1,21 @@ +Make sure you have read +- [How to configure tgcf](https://github.com/aahnik/tgcf/wiki/How-to-configure-tgcf-%3F) +- [Plugins](https://github.com/aahnik/tgcf/wiki/Plugins) + +The OCR plugin allows you to do Optical Character Recognition for images. + +If an image is posted in source chat, the image with text (ocr) caption will be sent to the destination chats. + +To activate the OCR plugin, just put the line `ocr:` under the plugins section of your configuration file. + +```yaml +plugins: + # ... your other plugins here + ocr: + # ... other plugins + +``` + +If you are running on your own computer,you must have [tesseract-ocr](https://github.com/tesseract-ocr/tesseract) installed in your system for this. + +If you are deploying to cloud platform, or running tgcf using the Docker method as per the instructions in the wiki, then there is nothing to worry. \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/_Footer.md b/.github/archives/tgcf_0.2_wiki/_Footer.md new file mode 100644 index 00000000..d18f277d --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/_Footer.md @@ -0,0 +1 @@ +Have a question? Ask in the [discussion forum](https://github.com/aahnik/tgcf/discussions). But make sure to **read the wiki** first. \ No newline at end of file diff --git a/.github/archives/tgcf_0.2_wiki/_Sidebar.md b/.github/archives/tgcf_0.2_wiki/_Sidebar.md new file mode 100644 index 00000000..a2df51ae --- /dev/null +++ b/.github/archives/tgcf_0.2_wiki/_Sidebar.md @@ -0,0 +1,3 @@ +

+ tgcf logo +