cisticola.transformer.telegram_telethon module

class cisticola.transformer.telegram_telethon.TelegramTelethonTransformer(telethon_session_name=None)

Bases: Transformer

bad_channels = {}
can_handle(data: ScraperResult) bool

Specifies whether or not a Transformer is capable of handling a particular piece of scraped data.

Parameters:

data (ScraperResult) – The ScraperResult object to check for ability to handle.

Returns:

True if it can be handled by this Transformer, false otherwise.

Return type:

bool

channels_cache_by_id = {}
channels_cache_by_platformid = {}
channels_cache_by_screenname = {}
get_name_from_web_interface(orig_screenname, id)
get_screenname_cache = {}
get_screenname_from_id(channel_id)
posts_cache = {}
transform(data: ScraperResult, insert: Callable, session: Session, flush_posts: Callable)

Transform a ScraperResult into objects with additional parameters for analysis. This function can yield multiple objects, as it will find references to quoted/replied posts, media objects, and Channel objects and provide all of these to be inserted into the database.

Parameters:
  • data (ScraperResult) – The ScraperResult object to process.

  • insert (Callable) – A function that either inserts the object into a database or finds an object with the relevant unique constraints if applicable.

transform_info(data: RawChannelInfo, insert: Callable, session, channel=None)

This function is necessary because Telethon’s markdown.unparse doesn’t correctly handle trailing whitespace or multi-line links

cisticola.transformer.telegram_telethon.stripped(s)

https://stackoverflow.com/a/29933716