Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added telegram_print function #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def train_your_nicest_model(your_nicest_parameters):
import time
time.sleep(10000)
return {'loss': 0.9} # Optional return value

#For sending direct message to telegram(Optional)
from knockknock import telegram_print

telegram_print(text="<your_text>",token="<your_api_token>", chat_id=CHAT_ID)
```

#### Command-line
Expand Down
7 changes: 7 additions & 0 deletions knockknock/telegram_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ def wrapper_sender(*args, **kwargs):
return wrapper_sender

return decorator_sender


def telegram_print(text:str,token: str, chat_id: int):
# telegram print sends the message to the telegram
# Ex: It can be used to send loss,accuracy during each epoch
bot = telegram.Bot(token=token)
bot.send_message(chat_id=chat_id, text=text)