GithubHelp home page GithubHelp logo

plain-ub's Introduction

PLAIN UB

Made for my personal use

Example Plugins:

  • Basic Plugin:
from app import BOT, bot, Message

@bot.add_cmd(cmd="test")
async def test_function(bot: BOT, message: Message):
    await message.reply("Testing....")
    """Your rest of the code."""
    
  • Plugin with Multiple Commands:
    Instead of stacking @add_cmd you can pass in a list of command triggers.
from app import BOT, bot, Message

@bot.add_cmd(cmd=["cmd1", "cmd2"])
async def test_function(bot: BOT, message: Message):
    if message.cmd=="cmd1":
        await message.reply("cmd1 triggered function")
    """Your rest of the code."""
    
  • Plugin with DB access:
from app import BOT, bot, Message, CustomDB

TEST_COLLECTION = CustomDB("TEST_COLLECTION")

@bot.add_cmd(cmd="add_data")
async def test_function(bot: BOT, message: Message):
    async for data in TEST_COLLECTION.find():
        """Your rest of the code."""
    # OR
    await TEST_COLLECTION.add_data(data={"_id":"test", "data":"some_data"})
    await TEST_COLLECTION.delete_data(id="test")
  • Conversational Plugin:
    • Bound Method

      from pyrogram import filters
      from app import BOT, bot, Message
      @bot.add_cmd(cmd="test")
      async def test_function(bot: BOT, message: Message):
          response = await message.get_response(
              filters=filters.text&filters.user([1234]), 
              timeout=10,
          )
          # Will return First text it receives in chat where cmd was ran
          """ rest of the code """
             
    • Conversational

      from app import BOT, bot, Message, Convo
      from pyrogram import filters
      
      @bot.add_cmd(cmd="test")
      async def test_function(bot: BOT, message: Message):
          async with Convo(
              client=bot, 
              chat_id=1234, 
              filters=filters.text, 
              timeout=10
          ) as convo:
              await convo.get_response(timeout=10)
              await convo.send_message(text="abc", get_response=True, timeout=8)
              # and so on
          

plain-ub's People

Contributors

thedragonsinn avatar billouetaudrey avatar

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.