Code Monkey home page Code Monkey logo

uniborg's Introduction

uniborg

Pluggable asyncio Telegram userbot based on Telethon.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public License for more details.

disclaimer

⚠️ This fork uses "requests" module in various places, instead of the async alternative. ⚠️

  • This was an attempt to learn userbot development using Telethon, this project is now no longer usable, and is FORKed and MODIFied to suit MY needs, so use at your own risk.

installing

The Easiest Way

  • Install Docker by following the official docker docs

  • Start docker daemon [skip if already running]:

dockerd
  • Build Docker image:
docker build . -t uniborg
  • Run the image:
docker run uniborg

It is not recommended to use "sudo", while using Docker. GNU/Linux Permissions are highly customisable, and it is generally not required to have "ROOT" permission, unless you know what you are doing. You can still install all the dependencies in your system [with ROOT permissions], but please be aware of the potential issues when doing so. The installed packages may conflict with the system package manager's installed packages, which can cause trouble down the road and errors when upgrading conflicting packages. You have been warned.

The Legacy Way

Simply clone the repository and run the main file:

git clone https://github.com/udf/uniborg.git
cd uniborg
python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt
cp sample_config.env config.env
# <edit config.env with appropriate values>
python3 -m kopp

internals

The core features offered by the custom TelegramClient live under the uniborg/ directory, with some utilities, enhancements, the _core plugin, and the _inline_bot plugin.

  • Only five of the environment variables are mandatory.
  • Please read the WiKi to understand the use of the variables.
  • This is because of telethon.errors.ApiIdPublishedFloodError
    • APP_ID:
    • API_HASH:
    • TG_BOT_TOKEN_BF_HER:
    • TG_BOT_USER_NAME_BF_HER:
    • DATABASE_URL:
  • The userbot should work without setting the non-mandatory environment variables.

design

The modular design of the project enhances your Telegram experience through plugins which you can enable or disable on demand.

Each plugin gets the borg, logger, Config magical variables to ease their use. Thus creating a plugin as easy as adding a new file under the plugin directory to do the job:

# stdplugins/myplugin.py
@borg.on(slitu.admin_cmd(pattern="hi"))
async def handler(event):
    await event.client.send_message(
        event.chat_id,
        "hey"
    )

learning

Check out the already-mentioned plugins directory, or some third-party plugins to learn how to write your own, and consider reading Telethon's documentation.

credits

Thanks to:

uniborg's People

Contributors

9ary avatar aykxt avatar baalajimaestro avatar cyberboysumanjay avatar expectocode avatar gautamajay52 avatar gauthamramravichandran avatar halodragon7410 avatar hashanant avatar hikaruichijyo avatar jaskaransm avatar lonami avatar lucciferoo7 avatar muhammedfurkan avatar nitanmarcel avatar nkonin avatar paulsonoflars avatar penn5 avatar phyco-ninja avatar rking32 avatar samadii avatar sourcery-ai[bot] avatar spechide avatar sunda001 avatar tgexplore avatar udf avatar vrumger avatar yusufusta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uniborg's Issues

[Help] How do I provide torrent functionality in Uniborg?

Hello!

I want to download torrents on Uniborg.

But in the setup of the heroku, I do not know what to write in the value section below.

"HASH_TO_TORRENT_API":
 {
     "description": "This is required for the hash to torrent file functionality to work.",
     "value": "https://example.com/torrent/{}",
     "required": false

Can you help me...
Thanks.

uploading subfolders doesnt works

when I try to upload a dir, it not uploads sub-dirs
example:

upload1
some files here
- thisisasubdir
- some files here
-- thisissubsubdir
-- some files here

when I give command
.uploadir upload1

it's not uploading subdirs. how to upload all of files (with all subdir files?)
you may try with a little sample. please fix. thank you :)

fixed

progress_str = "[{0}{1}]\nProgress: {2}%\n".format(

progress_str = "[{0}{1}]\nPercent: {2}%\n".format(
            ''.join("█" for _ in range(math.floor(percentage / 5))),
            ''.join("░" for _ in range(20 - math.floor(percentage / 5))),```

Great Repository, Lack of documentation.

I just feel that i have to read the entire python code, to understand what can I do with a Single plugin.
I suggest to write a comment on top of the plugin, to best describe what it does and what are the possible outputs including errors (including inner-branches on how the message is handled depending on type for example).

This is a great tool, for those like me who based their life on Telegram, and want tools to improve efficency.

Unpack requires a buffer of 275 bytes

i am trying to deploy this app on heroku. I set the following environment variables

APP_ID
API_HASH
HU_STRING_SESSION

Then i tried to run application on heroku and i am facing following error.
Traceback (most recent call last): File "/app/.heroku/python/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/app/.heroku/python/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/app/stdborg.py", line 42, in <module> StringSession(session_name), File "/app/.heroku/python/lib/python3.7/site-packages/telethon/sessions/string.py", line 38, in __init__ _STRUCT_PREFORMAT.format(ip_len), StringSession.decode(string)) struct.error: unpack requires a buffer of 275 bytes

and same error pops up on my local pc.

Traceback (most recent call last): File "C:/Users/myname/PycharmProjects/bot/telesetup.py", line 15, in <module> client = TelegramClient(StringSession(api_session), File "C:\Users\myname\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telethon\sessions\string.py", line 38, in __init__ _STRUCT_PREFORMAT.format(ip_len), StringSession.decode(string)) struct.error: unpack requires a buffer of 275 bytes

anyone can help me what should i do?

Problem with Aria Two Plugin

On adding a magnet the download gets successful but god knows to which directory it gets downloaded to.I checked TMP_DOWNLOAD_DIRECTORY and root directory but the weren't there.So, I can't even upload the aria2 downloaded files to telegram which makes the plugin useless.Please look after this🥺

Instant crash after deploy on Heroku (maybe dice's fault)


Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/app/.heroku/python/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/app/stdborg.py", line 46, in <module>
    api_hash=Config.API_HASH
  File "/app/uniborg/uniborg.py", line 61, in __init__
    self.load_plugin_from_file(a_plugin_path)
  File "/app/uniborg/uniborg.py", line 108, in load_plugin_from_file
    spec.loader.exec_module(mod)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "stdplugins/dice.py", line 3, in <module>
    from telethon.tl.types import InputMediaDice
ImportError: cannot import name 'InputMediaDice' from 'telethon.tl.types' (/app/.heroku/python/lib/python3.7/site-packages/telethon/tl/types/__init__.py)

As title says, I tried to execute the Dyno command (python3 -m stdborg) directly with the "Run console" feature because .helpme didn't work and I found out this error.

My attempt was to remove the said file (dice.py) and suddently, at least until I kept the Heroku bash shell opened, the bot worked, because you can't modify Dyno's files.

Aria2 torrent download commands don't work.

Although I added a high-seed torrent, there is no reaction.

Screenshot_1


Downloading doesn't start when I add using .exec.

[#b49343 0B/0B CN:0 SD:0 DL:0B]`
[#b49343 0B/0B CN:0 SD:0 DL:0B]`
[#b49343 0B/0B CN:0 SD:0 DL:0B]`
[#b49343 0B/0B CN:0 SD:0 DL:0B]`
[#b49343 0B/0B CN:0 SD:0 DL:0B]`
[#b49343 0B/0B CN:0 SD:0 DL:0B]`
[#b49343 0B/0B CN:0 SD:0 DL:0B]`
[#b49343 0B/0B CN:0 SD:0 DL:0B]`
 *** Download Progress Summary as of Mon Jul  6 11:17:56 2020 *** `
===============================================================================`
[#b49343 0B/0B CN:0 SD:0 DL:0B]`
FILE: [MEMORY][METADATA]Internet+Download+Manager+6.38+Build+1+|+One+Click+PreActivated+|+RePack+Multi+Language`
-------------------------------------------------------------------------------`

stdborg.py crached

image

2019-05-06T15:01:03.000000+00:00 app[api]: Build succeeded 2019-05-06T15:01:11.158243+00:00 heroku[worker.1]: Starting process with command python3 -m stdborg2019-05-06T15:01:11.704311+00:00 heroku[worker.1]: State changed from starting to up 2019-05-06T15:01:15.948236+00:00 heroku[worker.1]: State changed from up to crashed 2019-05-06T15:01:15.929834+00:00 heroku[worker.1]: Process exited with status 1 2019-05-06T15:01:15.796701+00:00 app[worker.1]: Traceback (most recent call last): 2019-05-06T15:01:15.796786+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/runpy.py", line 193, in _run_module_as_main 2019-05-06T15:01:15.797842+00:00 app[worker.1]: "__main__", mod_spec) 2019-05-06T15:01:15.797876+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/runpy.py", line 85, in _run_code 2019-05-06T15:01:15.798205+00:00 app[worker.1]: exec(code, run_globals) 2019-05-06T15:01:15.798239+00:00 app[worker.1]: File "/app/stdborg.py", line 43, in <module> 2019-05-06T15:01:15.798484+00:00 app[worker.1]: StringSession(session_name), 2019-05-06T15:01:15.798586+00:00 app[worker.1]: NameError: name 'StringSession' is not defined

Error with python3 -m stdborg SESSION

Hello,
i was trying the install instructions but i always come to this error :

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/root/montather/stdborg.py", line 9, in <module>
    from uniborg import Uniborg
  File "/root/montather/uniborg/__init__.py", line 5, in <module>
    from .uniborg import *
  File "/root/montather/uniborg/uniborg.py", line 60
    for a_plugin_path in Path().glob(f"{self.n_plugin_path}/*.py"):
                                                                ^
SyntaxError: invalid syntax

i have python 3.5
Im not very good with python so there might be something wrong im doing ?

Chrome on heroku

When i am trying to use module "screencapture" it says "need to install Google Chrome. Module Stopping.", But I'm hosting my userbot on heroku. How to install chrome on it?

DB_URI is required

Code in master stdborg.py:


if Config.DB_URI is None:
  logging.warning("No DB_URI Found!")
  sys.exit(1)

[Feature Request] Add SpamWatch integration

I would suggest adding integration with SpamWatch so user bots can also banhammer spammers on SpamWatch.

TO-DO for Maintainers

If you agree with my suggestion, please follow this to-do. Anyone can use this to-do to craft their own Merge Requests containing the SpamWatch integration.

  • Add spamwatch to the requirements.txt.
  • Pull plugins/autobahn files from Kantek.
  • Add SPAMWATCH_API_TOKEN and SPAMWATCH_API_HOST (for self-hosted SpamWatch API servers) to configuration.
  • If those config keys are undefined, disable Kantek plugins.
  • If the SPAMWATCH_API_HOST config key is undefined, automatically point API requests to https://api.spamwat.ch
  • Run CI dry-runs and manual testing to confirm its works.

Notes

  • From Kantek's README:

Kantek is mostly built to help with the Administration of chats and is the main source for SpamWat.ch. Because of that it checks every message your account receives for blacklisted items, this includes strings, domains, top level domains, files, images and telegram entities. This means that for every message your account receiver kantek might make multiple http requests an resolve multiple telegram entities. The latter might lead to large (6+ hours) Floodwaits from Telegram.

.afk

afk command does not work

Facing issues while uploading Folders

INFO:oauth2client.client:Refreshing access_token
2020-02-21T06:43:50.692397+00:00 app[worker.1]: INFO:googleapiclient.discovery:URL being requested: GET https://www.googleapis.com/discovery/v1/apis/drive/v2/rest
2020-02-21T06:43:50.833696+00:00 app[worker.1]: INFO:googleapiclient.discovery:URL being requested: POST https://www.googleapis.com/drive/v2/files?alt=json
2020-02-21T06:43:51.689404+00:00 app[worker.1]: INFO:googleapiclient.discovery:URL being requested: POST https://www.googleapis.com/drive/v2/files/1gITrE7arf9KLNSvD6V4rlcYvxkDS-jLY/permissions?alt=json
2020-02-21T06:43:52.570402+00:00 app[worker.1]: INFO:gDrive:Created Gdrive Folder:
2020-02-21T06:43:52.570414+00:00 app[worker.1]: Name: [Foxtrot] Vinland Saga - Volume 1 [BD 720p AAC]
2020-02-21T06:43:52.570415+00:00 app[worker.1]: ID: 1gITrE7arf9KLNSvD6V4rlcYvxkDS-jLY
2020-02-21T06:43:52.570797+00:00 app[worker.1]: INFO:googleapiclient.discovery:URL being requested: GET https://www.googleapis.com/discovery/v1/apis/drive/v2/rest
2020-02-21T06:43:52.717082+00:00 app[worker.1]: INFO:googleapiclient.discovery:URL being requested: POST https://www.googleapis.com/upload/drive/v2/files?alt=json&uploadType=resumable
2020-02-21T06:43:54.931733+00:00 app[worker.1]: ERROR:telethon.client.updates:Unhandled exception on _
2020-02-21T06:43:54.931743+00:00 app[worker.1]: Traceback (most recent call last):
2020-02-21T06:43:54.931744+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/telethon/client/updates.py", line 428, in _dispatch_update
2020-02-21T06:43:54.931745+00:00 app[worker.1]: await callback(event)
2020-02-21T06:43:54.931745+00:00 app[worker.1]: File "stdplugins/gDrive.py", line 164, in _
2020-02-21T06:43:54.931745+00:00 app[worker.1]: await DoTeskWithDir(http, input_str, mone, dir_id)
2020-02-21T06:43:54.931746+00:00 app[worker.1]: File "stdplugins/gDrive.py", line 365, in DoTeskWithDir
2020-02-21T06:43:54.931747+00:00 app[worker.1]: g_drive_link = await upload_file(http, current_file_name, file_name, mime_type, event, parent_id)
2020-02-21T06:43:54.931747+00:00 app[worker.1]: File "stdplugins/gDrive.py", line 299, in upload_file
2020-02-21T06:43:54.931747+00:00 app[worker.1]: status, response = file.next_chunk()
2020-02-21T06:43:54.931748+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
2020-02-21T06:43:54.931748+00:00 app[worker.1]: return wrapped(*args, **kwargs)
2020-02-21T06:43:54.931749+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/googleapiclient/http.py", line 988, in next_chunk
2020-02-21T06:43:54.931749+00:00 app[worker.1]: headers=headers)
2020-02-21T06:43:54.931749+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/oauth2client/transport.py", line 175, in new_request
2020-02-21T06:43:54.931750+00:00 app[worker.1]: redirections, connection_type)
2020-02-21T06:43:54.931750+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/oauth2client/transport.py", line 282, in request
2020-02-21T06:43:54.931751+00:00 app[worker.1]: connection_type=connection_type)
2020-02-21T06:43:54.931751+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/httplib2/init.py", line 1991, in request
2020-02-21T06:43:54.931752+00:00 app[worker.1]: cachekey,
2020-02-21T06:43:54.931753+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/httplib2/init.py", line 1690, in _request
2020-02-21T06:43:54.931753+00:00 app[worker.1]: content,
2020-02-21T06:43:54.931754+00:00 app[worker.1]: httplib2.RedirectMissingLocation: Redirected but the response is missing a Location: header.

whois

whois extention doesnt work properly.

app[worker.1]:

File "stdplugins/whois.py", line 56, in _2019-04-16T20:29:41.368974+00:00

app[worker.1]:

user_bio = html.escape(replied_user.about)2019-04-16T20:29:41.368976+00:00

app[worker.1]: 

File "/app/.heroku/python/lib/python3.7/html/init.py", line 19, in escape2019-04-16T20:29:41.368977+00:00

app[worker.1]:

s = s.replace("&", "&amp;") # Must be done first!2019-04-16T20:29:41.368978+00:00 app[worker.1]: AttributeError: 'NoneType' object has no attribute 'replace'

DON'T DO THIS ..!!!

  • ff_mpeg.py

re-write the code:
remember what happened on October 25, 2018 08:20:15 IST? 😐😐

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.