🤬
  • Full refactoring. - Bug Fixes - Refactoring the whole code - Introducing testing ### TODO complete the message group processing ### Tests ### TODO introducing bot analysis ### TODO introducing chat group overlaps

  • Loading...
  • Giacomo Giallombardo committed 1 year ago
    7f230357
    1 parent 0b8a6a32
  • ■ ■ ■ ■ ■ ■
    src/telepathy/utils.py
    1 1  from colorama import Fore, Style
    2 2  from googletrans import Translator
    3  -from telepathy.const import __version__, user_agent
     3 +from const import __version__, user_agent
    4 4  import requests
    5 5  import textwrap
    6 6  from bs4 import BeautifulSoup
    7 7  import random
     8 +import os
    8 9   
    9 10  def createPlaceholdeCls():
    10 11   class Object(object):
    skipped 15 lines
    26 27   -- Developed by @jordanwildon | Version """ + __version__ + """.
    27 28   """ + Style.RESET_ALL
    28 29   )
     30 + 
     31 + 
    29 32   
    30 33  def parse_tg_date(dd):
    31 34   year = str(format(dd.year, "02d"))
    skipped 132 lines
    164 167   )
    165 168   except:
    166 169   total_participants = "Not found"
    167  - 
    168 170   return {"name":name,"group_description":group_description, "total_participants":total_participants}
    169 171   
    170 172   
    skipped 36 lines
    207 209   
    208 210   d_wrapper = generate_textwrap("Description:")
    209 211   td_wrapper = generate_textwrap("Translated Description:")
    210  - 
    211 212   color_print_green(" ┬ Chat details", "")
    212 213   color_print_green(" ├ Title: ", str(obj.title))
    213 214   color_print_green(" ├ ", d_wrapper.fill(obj.group_description))
    skipped 138 lines
    352 353   " ├ Top forward source 5: ", str(obj.forward_five)
    353 354   )
    354 355   color_print_green(" └ Edgelist saved to: ", obj.edgelist_file)
     356 + 
     357 +def create_path(path_d):
     358 + if not os.path.exists(path_d):
     359 + os.makedirs(path_d)
     360 + return path_d
     361 + 
     362 +def create_file_report(save_dir,name,type,extension,file_time,append_time=True):
     363 + _time_append = ""
     364 + if append_time:
     365 + _time_append = "_"+file_time
     366 + return os.path.join("{}".format(save_dir),"{}{}_{}.{}".format(name,_time_append,type,extension))
     367 + 
     368 +def clean_private_invite(url):
     369 + if "https://t.me/+" in url:
     370 + return(url.replace('https://t.me/+', 'https://t.me/joinchat/'))
     371 + 
     372 +def evaluate_reactions(message):
     373 + total_reactions = 0
     374 + reactions = {}
     375 + if message.reactions:
     376 + reactions = message.reactions.results
     377 + i = range(len(reactions))
     378 + for idx, i in enumerate(reactions):
     379 + total_reactions = total_reactions + i.count
     380 + reactions["thumbs_up"] = i.count if i.reaction == '👍' else 0
     381 + reactions["thumbs_down"] = i.count if i.reaction == '👎' else 0
     382 + reactions["heart"] = i.count if i.reaction == '❤️' else 0
     383 + reactions["fire"] = i.count if i.reaction == '🔥' else 0
     384 + reactions["smile_with_hearts"] = i.count if i.reaction == '🥰' else 0
     385 + reactions["clap"] = i.count if i.reaction == '👏' else 0
     386 + reactions["smile"] = i.count if i.reaction == '😁' else 0
     387 + reactions["thinking"] = i.count if i.reaction == '🤔' else 0
     388 + reactions["exploding_head"] = i.count if i.reaction == '🤯' else 0
     389 + reactions["scream"] = i.count if i.reaction == '😱' else 0
     390 + reactions["angry"] = i.count if i.reaction == '🤬' else 0
     391 + reactions["single_tear"] = i.count if i.reaction == '😢' else 0
     392 + reactions["party_popper"] = i.count if i.reaction == '🎉' else 0
     393 + reactions["starstruck"] = i.count if i.reaction == '🤩' else 0
     394 + reactions["vomiting"] = i.count if i.reaction == '🤮' else 0
     395 + reactions["poop"] = i.count if i.reaction == '💩' else 0
     396 + reactions["praying"] = i.count if i.reaction == '🙏' else 0
     397 + else:
     398 + reactions["total_reactions"] = 'N/A'
     399 + reactions["thumbs_up"] = 'N/A'
     400 + reactions["thumbs_down"] = 'N/A'
     401 + reactions["heart"] = 'N/A'
     402 + reactions["fire"] = 'N/A'
     403 + reactions["smile_with_hearts"] = 'N/A'
     404 + reactions["clap"] = 'N/A'
     405 + reactions["smile"] = 'N/A'
     406 + reactions["thinking"] = 'N/A'
     407 + reactions["exploding_head"] = 'N/A'
     408 + reactions["scream"] = 'N/A'
     409 + reactions["angry"] = 'N/A'
     410 + reactions["single_tear"] = 'N/A'
     411 + reactions["party_popper"] = 'N/A'
     412 + reactions["starstruck"] = 'N/A'
     413 + reactions["vomiting"] = 'N/A'
     414 + reactions["poop"] = 'N/A'
     415 + reactions["praying"] = 'N/A'
     416 + return total_reactions, reactions
     417 + 
     418 + 
Please wait...
Page is in error, reload to recover