Telegram interface to Pastebin.com: paste your code directly to a group and get a Pastebin link.
Try it »
Report Bug
·
Leia em Português
- About the Project
- Basic Usage
- Getting Started (for developers and curious)
- Contributing
- Roadmap
- License
- Contact
Pastebin.com is online since 2002. Many people use it to share code and get help, also in Telegram groups. PastebinTGBot allows you to create pastebins directly in your groups or at least within Telegram.
This project uses Python as programming language and is free hosted on Heroku. It also uses the following resources.
This project is developed and maintained by Heliton Martins. You can contact me on Telegram.
To use the bot, you can access it on Telegram (@PastebinTGBot) and click Start
. Then you can use the command /help
to see the complete Usage or just send your text/code. To create a Pastebin containing "Hello World", send this to the bot:
Hello World
which is completely equivalent to
/paste Hello World
To use the bot in a group, just add it to the group. Admin privilege is not required, but add functionality. When the bot is a normal member, it will reply to any message starting with /paste
or /paste@PastebinTGBot
and parse the content according to the rules (discussed below). However, if the bot has permission to delete messages, it'll send the link and delete the original message. It will avoid visual pollution in your group.
To create a Pastebin containing "Hello World" in a group, send this to the group:
/paste Hello World
which is completely equivalent to:
/paste@PastebinTGBot Hello World
When creating a paste, you can adjust three options (so far): the syntax highlighting, the expiring time, and the visibility of the paste. These options are expected:
- Privacy:
public
(default)unlisted
- Expiring time:
N
: Never (default)10M
: 10 Minutes1H
: 1 Hour1D
: 1 Day1W
: 1 Week2W
: 2 Weeks1M
: 1 Month
- Syntax Highlighting:
- 253 languages are currently supported. Click here to see the full list.
When these flags are found at the beginning of the message, they are considered and removed. If there are two flags of the same category, only the first is considered and the parsing stops. For example, the string
javascript 10M Hello World
will be parsed as "Hello World", formatted as Javascript, and persisted for 10 Minutes. On the other hand, the following string
javascript haskell Hello World
will be parsed as "haskell Hello World" and formatted as Javascript.
These flags must be at the first line. If you need to begin your pastebin with the word Julia (and don't want syntax highlighting), you should send this:
/paste
Julia is a relatively new, but very good language.
To get a local copy up and running follow these simple steps.
- Clone the PastebinTGBot and enter the directory
$ git clone https://github.com/hellmrf/PastebinTGBot.git
$ cd PastebinTGBot
Beginners tip: you'll see shell commands like this: $ something
. In this case, type just something
in your Terminal. $
indicates "shell input".
-
Make sure you have Python ≥ 3.7 and pip.
-
You can create a new virtual environment, but it's optional
- Install dependencies
$ pip install -r requirements.txt
-
Create your Telegram Bot with @BotFather and get your token.
-
Create an account on Pastebin.com to get you
api_dev_key
(here). -
To test the bot, you'll need a public (and https protected) IP. This usually means a server, but for development, you can use ngrok.
Download and install ngrok for your system and run the following command in a terminal:
$ ngrok http 127.0.0.1:8443
You'll see something like that:
Forwarding https://d1bf0d3b0d39.ngrok.io -> http://127.0.0.1:8443
In this case, https://d1bf0d3b0d39.ngrok.io
is your public URL (WEBHOOK_URL
below). Let the terminal running.
- Create a
.env
file in the folderpastebintgbot
(the same folder asmain.py
) containing:
TELEGRAM_TOKEN=
PASTEBIN_TOKEN=
HOST=127.0.0.1
PORT=8443
WEBHOOK_URL=
You can change the IP and the port, but it must match the ngrok command.
Windows users: make sure the file has the exact filename .env
. You may need to configure Explorer to show extensions.
- If everything is ok, run the bot.
$ python pastebintgbot/main.py
You should see something similar to this output (maybe more colorful) and you're good to go.
2021-01-01 00:00:00 you root[20513] INFO Server started on 127.0.0.1:8443. Listening publicily on https://d1bf0d3b0d39.ngrok.io/<token>
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin AmazingFeature
) - Open a Pull Request
I will analyze your PR as soon as possible.
See the open issues for a list of proposed features (and known bugs).
Distributed under the MIT License. See LICENSE
for more information.
Heliton Martins - @hellmrf - [email protected]
Project Link: https://github.com/hellmrf/PastebinTGBot