-
-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #478 from MobCode100/main
[Plugin] Sender
- Loading branch information
Showing
8 changed files
with
123 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import logging | ||
import sys | ||
|
||
from tgcf.plugins import TgcfMessage, TgcfPlugin | ||
from tgcf.config import CONFIG, get_SESSION | ||
from telethon import TelegramClient | ||
|
||
class TgcfSender(TgcfPlugin): | ||
id_ = "sender" | ||
|
||
async def __ainit__(self) -> None: | ||
sender = TelegramClient( | ||
get_SESSION(CONFIG.plugins.sender, 'tgcf_sender'), | ||
CONFIG.login.API_ID, | ||
CONFIG.login.API_HASH, | ||
) | ||
if self.data.user_type == 0: | ||
if self.data.BOT_TOKEN == "": | ||
logging.warning("[Sender] Bot token not found, but login type is set to bot.") | ||
sys.exit() | ||
await sender.start(bot_token=self.data.BOT_TOKEN) | ||
else: | ||
await sender.start() | ||
self.sender = sender | ||
|
||
async def modify(self, tm: TgcfMessage) -> TgcfMessage: | ||
tm.client = self.sender | ||
if tm.file_type != "nofile": | ||
tm.new_file = await tm.get_file() | ||
tm.cleanup = True | ||
return tm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters