Git Product home page Git Product logo

pastebintgbot's Introduction


PastebinTGBot Bot

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

Contributors Forks Stargazers Issues MIT License LinkedIn

Table of Contents

About The Project

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.

Built With

This project uses Python as programming language and is free hosted on Heroku. It also uses the following resources.

Author

This project is developed and maintained by Heliton Martins. You can contact me on Telegram.

Basic Usage

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

Using in groups

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

Special options

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 Minutes
    • 1H: 1 Hour
    • 1D: 1 Day
    • 1W: 1 Week
    • 2W: 2 Weeks
    • 1M: 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.

Getting Started (for developers and curious)

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 folder pastebintgbot (the same folder as main.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>

Contributing

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin AmazingFeature)
  5. Open a Pull Request

I will analyze your PR as soon as possible.


Roadmap

See the open issues for a list of proposed features (and known bugs).

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Heliton Martins - @hellmrf - [email protected]

Project Link: https://github.com/hellmrf/PastebinTGBot

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.