Skip to content

Commit

Permalink
Merge pull request #117 from aahnik/dev
Browse files Browse the repository at this point in the history
Make delete sync optional and fix whitelist issue
  • Loading branch information
aahnik authored May 4, 2021
2 parents 6a785cd + 3f6b368 commit 1ea9304
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/tgcf_filter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, data):

def modify(self, message):
msg_text = message.text
if not msg_text:
if not msg_text and self.filters.text.whitelist == []:
return message

if self.text_safe(msg_text, self.filters.text):
Expand Down
9 changes: 9 additions & 0 deletions plugins/tgcf_ocr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

class TgcfOcr:
id = "ocr"

def __init__(self, data) -> None:
pass

def modify(self, message):
pass
9 changes: 9 additions & 0 deletions plugins/tgcf_watermark/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

class TgcfWatermark:
id = "watermark"

def __init__(self, data) -> None:
pass

def modify(self, message):
pass
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tgcf"
version = "0.1.25.post1"
version = "0.1.26"
description = "The ultimate tool to automate telegram message forwarding."
authors = ["aahnik <[email protected]>"]
license = "MIT"
Expand All @@ -11,6 +11,8 @@ packages = [
{ include = "tgcf"},
{ include = "tgcf_filter", from = "plugins" },
{ include = "tgcf_replace", from = "plugins" },
{ include = "tgcf_watermark", from = "plugins" },
{ include = "tgcf_ocr", from = "plugins" },
]

[tool.poetry.dependencies]
Expand Down
14 changes: 10 additions & 4 deletions tgcf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import os
import sys
from typing import Dict, List, Optional,Union
from typing import Dict, List, Optional, Union

import yaml
from pydantic import BaseModel
Expand All @@ -14,14 +14,20 @@


class Forward(BaseModel):
source: Union[int,str]
dest: List[Union[int,str]]
source: Union[int, str]
dest: List[Union[int, str]]
offset: Optional[int] = 0


class LiveSettings(BaseModel):
delete_sync: Optional[bool] = False


class Config(BaseModel):
forwards: List[Forward]
show_forwarded_from: Optional[bool] = False
live: Optional[LiveSettings] = LiveSettings()

plugins: Optional[Dict] = {}


Expand Down Expand Up @@ -51,7 +57,7 @@ def detect_config_type() -> int:
CONFIG_TYPE = detect_config_type()


def read_config_file():
def read_config_file()->Config:
if CONFIG_TYPE == 1:
with open(CONFIG_FILE_NAME) as file:
config_dict = yaml.full_load(file)
Expand Down
4 changes: 3 additions & 1 deletion tgcf/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ async def deleted_message_handler(event):
def start_sync():
client = TelegramClient(SESSION, API_ID, API_HASH)
for key, val in ALL_EVENTS.items():
logging.info(f"Added event handler for {key}")
if CONFIG.live.delete_sync is False and key == "deleted":
continue
client.add_event_handler(*val)
logging.info(f"Added event handler for {key}")
client.start()
client.run_until_disconnected()

0 comments on commit 1ea9304

Please sign in to comment.