Skip to main content

An edited 1.24.0 version of the full-featured Telegram client library for Python 3

Project description

About

A simple clone of the awesome Telegram MTproto client version 1.24.0 but with up to date components, You do not have to change previous code with telethon, as there are no breaking changes.

install: (if any issues, try uninstalling telethon first):

pip install -U newthon

Reactions

client.send_reaction(chat, message, "😢")

or shorter:

message.react("😁", big=True)

to send a reaction with animation(for pms) use big=True, and, to remove a reaction use remove=True:

message.react(remove=True)

Premium

  • You can send files larger that 2GiB through Telegram

  • Premium users will have .premium in their user object

  • Premium stickers will also have .premium that might need dealing if you don’t have subscription.

spoilers and custom emoji

Use ||Text|| to create spoilers, for HTML use <tg-spoiler>Text</tg-spoiler> to create a customEmoji markdown use <emoji id=”5373101475679443553”>😉</emoji>. the id being the document id of any CustomEmoji Document.id in its pack.

Requests of join and events for ChatAction events

  • event.new_invite (only for bot accounts)

@bot.on(events.ChatAction(func=lambda e : e.new_join_request))
async def _(event):
    event.approve_user(approved=True or False)
  • event.new_approve for user accounts

@client.on(events.ChatAction(func=lambda e : e.new_approve))
async def _(event):
    event.approve_user(approved=True/False)

using raw api to accept old requests

  • Getting them

result = client(functions.messages.GetChatInviteImportersRequest(
    peer="chat",
    offset_date=None,
    offset_user=telethon.tl.types.InputUserEmpty(),
    limit=1000
))
  • manual approve

for a in result:
    client(functions.messages.HideChatJoinRequestRequest(
        peer='chat or username',
        user_id='To-approve',
        approved=True or False
    ))
  • batch approve:

client(functions.messages.HideAllChatJoinRequestsRequest(
    peer=entity,
    approved=True or False
))

WebView Button

You can input a web bot button as an inline button or a keyboard button, sine it can be both. the default is inline button, you can use the inline=False to use it in a keyboard button

from telethon import Button
client.send_message(chat, "Open Google", buttons=Button.web("google", "https://google.com")
  • note that webapp keyboard can be only a single button, it won’t allow others with it.

client.send_message(chat, "YouTube", buttons=Button.web("google", "https://YouTube.com", inline=False)

Content privacy

chat.noforwards will return True for chats with forward restriction enabled, same applies to bot messages with message.noforwards You can use the argument noforwards=True in sender methods.

client.send_message(chat, "lonami is god", noforwards=True)

iter_participant

aggressive True will sleep by default. its sleep value can be adjusted using the sleep parameter, this will make it sleep for that specified amount before processing next chunk.

client.get_participant(chat, aggressive=True, sleep=2)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

newthon_fixed-1.27.6.tar.gz (496.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

newthon_fixed-1.27.6-py3-none-any.whl (561.7 kB view details)

Uploaded Python 3

File details

Details for the file newthon_fixed-1.27.6.tar.gz.

File metadata

  • Download URL: newthon_fixed-1.27.6.tar.gz
  • Upload date:
  • Size: 496.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for newthon_fixed-1.27.6.tar.gz
Algorithm Hash digest
SHA256 559734237c42411702cbc7b436cb10058a58b7301da148193ff9d82b93d0723a
MD5 fc0abf6aa5b718e6d2a9a8cccbd7ffa9
BLAKE2b-256 34b93b81a3b014689033384a4fc62385912fc97abd5ab5529fe6496f9ac52691

See more details on using hashes here.

File details

Details for the file newthon_fixed-1.27.6-py3-none-any.whl.

File metadata

  • Download URL: newthon_fixed-1.27.6-py3-none-any.whl
  • Upload date:
  • Size: 561.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for newthon_fixed-1.27.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7d5e05cadd7d26675035201507ff7b7e3e25af9c1528a395cf4e05d4968696be
MD5 ffc15a0e98b152077f6cb344cacaa682
BLAKE2b-256 920c09ee402789a60e1cf3b4b458e5949d89b5e82361e4f020c2f25f7ab9f049

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page