Giter Club home page Giter Club logo

tgpy's People

Contributors

actions-user avatar ntoneee avatar purplesyringa avatar sgnusov avatar tm-a-t avatar vanutp avatar weethet 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

Watchers

 avatar  avatar

tgpy's Issues

Suggest your recipes here

We’re starting recipes, short TGPy tutorials: https://tgpy.tmat.me/recipes

Write a recipe in comments!

Here are some ideas for inspiration:

  • Show how you have set up TGPy for regular usage.
  • Describe a trick that you often use.
  • Share an unusual use case that you found.

Please include code and at least some explanation. There are no strict rules for the format, but remember your recipe should be interesting for other users.

If we find your recipe helpful, we will publish it on the site.

Improvements to cancel command

  • ability to stop running commands (implemented in 547c1c6)
  • ability to stop sync commands such as while True loop
  • make cancel and // permanent (do not reevaluate message when editing, if it was cancelled before) (implemented in bae83e2)

Customizability

  • сделать MessageModel вместо message_design.py, чтобы в нем были все функции и константы оттуда, которые можно было бы переопределять
  • сделать MessageParser вместо ast.parse
  • сделать возможным через апи менять MessageModel, MessageParser и variables (который сейчас в builtin_functions.py)
  • сделать builtin hooks, которые можно будет частично отключать в конфиге
  • переименовать hooks в modules

False positive code detections

  • 1. Multiple one-word lines
word
another_word
...
  • 2. Tuple word, another_word, ...

  • 3. Single hyphen confused with binary subtraction operator w-ord

  • 4. URLs example.com or t.me/username or t.me/c/1234567890/1000

  • 5. Email addresses [email protected]

  • 6. not good

  • 7. Unary operators to constant-1

  • 8. 1 + 3

a - b, c
d - e, f

First line in traceback isn't shown in some cases

First line in traceback isn't shown when function is not awaited in message, thus awaited by meval instead. In this case, this line is skipped, because it's not message's code

Example:
Original traceback:

async def delete():
    ctx_orig = await ctx.msg.get_reply_message()
    await ctx_orig.delete()
    await ctx.msg.delete()
delete()

TGPy> Error occurred

Traceback (most recent call last):
  File ".../app/run_code/meval.py", line 177, in <listcomp>
    ret = [await el if inspect.isawaitable(el) else el for el in ret]
  File "tgpy://message/...", line 3, in delete
    await ctx_orig.delete()
AttributeError: 'NoneType' object has no attribute 'delete'

Stripped traceback:

Traceback (most recent call last):
  File "tgpy://message/...", line 3, in delete
    await ctx_orig.delete()
AttributeError: 'NoneType' object has no attribute 'delete'

Do not show all fields in tl objects when they are returned

For example, when message is sent using await msg.reply('123'), Message object is returned and a lot of fields are shown, spamming in the chat.

For instance:

msg
TGPy> Message(
 id=123,
 peer_id=PeerChannel(
  channel_id=1123456789
 ),
 date=datetime.datetime(2021, 11, 18, 18, 7, 4, tzinfo=datetime.timezone.utc),
 message='msg',
 out=True,
 mentioned=False,
 media_unread=False,
 silent=False,
 post=False,
 from_scheduled=False,
 legacy=False,
 edit_hide=False,
 pinned=False,
 from_id=PeerUser(
  user_id=123456
 ),
 fwd_from=None,
 via_bot_id=None,
 reply_to=None,
 media=None,
 reply_markup=None,
 entities=[
 ],
 views=None,
 forwards=None,
 replies=MessageReplies(
  replies=0,
  replies_pts=...,
  comments=False,
  recent_repliers=[
  ],
  channel_id=None,
  max_id=None,
  read_max_id=None
 ),
 edit_date=None,
 post_author=None,
 grouped_id=None,
 restriction_reason=[
 ],
 ttl_period=None
)

Proposal is to show only commonly used fields, such as id, text, date, fwd_from, etc.
Also, this could be done for User, Channel, Chat too

Two-factor authentication password is shown in the console

Steps to reproduce

Run TGPy for the first time:

> vim config.py
> virtualenv venv
> source venv/bin/activate.fish
> pip install -r requirements.txt
> python -m app

< INFO:    Connecting to 149.154.167.51:443/TcpFull...
< INFO:    Connection to 149.154.167.51:443/TcpFull complete!
< Please enter the code you received: 12345
< 2FA password: <!plain text password here>
< Signed in successfully as ...

Expected behaviour

The password is not shown or at least shown in stars (for example, ********** for 10-symbol password)

Behaviour seen

The password is shown in plain text, which is insecure when running TGPy in a public place

Rewrite in rust

Rust is a memory-safe and secure language and is more efficient than Python. It is type safe and has better telegram support. Also, the industry trend is shifting towards Rust so we should rewrite this in Rust.

Hide error traceback

TGPy messages with errors look quite like random spam, and full error tracebacks are rarely useful.

I am proposing to show only the last line of the error and save the full error to a variable and/or logs.

Example

Current behavior:

msg.something

TGPy> Error occurred

Traceback (most recent call last):
  File "/home/tmat/.local/pipx/venvs/tgpy/lib/python3.11/site-packages/tgpy/_core/meval.py", line 175, in _meval
    new_locs, ret = await getattr(py_module, 'tmp')(**kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "tgpy://message/-1001611149679/38326", line 1, in tmp
    msg.something
AttributeError: 'Message' object has no attribute 'something'

Suggested behavior:

msg.something

TGPy> AttributeError: 'Message' object has no attribute 'something'

Commands?

Think how commands can be implemented and if it should be done at all

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.