-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 907e3fb
Showing
3 changed files
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
token.txt |
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,12 @@ | ||
# RaspiControl-Bot | ||
Recieve status data from your RaspberryPi via a Telegram Bot. | ||
|
||
## How to use: | ||
|
||
Create a now bot via the @BotFather on Telegram and copy the token. | ||
|
||
Clone this repository onto your RaspberryPi. | ||
In this folder, create a file named "token.txt" and paste your bot token into it. | ||
You also have to open your terminal and install: | ||
`pip install gpiozero` and `pip install python-telegram-bot` | ||
Now run the `raspicontrol.py` script. |
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,37 @@ | ||
import telegram.ext | ||
from gpiozero import CPUTemperature | ||
|
||
with open('token.txt', 'r') as f: | ||
TOKEN = f.read() | ||
|
||
cpu = CPUTemperature() | ||
|
||
def start(update): | ||
update.message.replay_text("Hey! Welcome to RaspiControl. I'm a bot that can send you status data about your Raspberry Pi.") | ||
|
||
def help(update): | ||
update.message.replay_text(""" | ||
The following commands are avaiable: | ||
/start -> Welcome Message | ||
/help -> This Message | ||
/temp -> Current CPU temperature | ||
/contact -> Information about the developer | ||
""") | ||
|
||
def temp(update): | ||
update.message.replay_text("The current CPU temperature is: " + cpu.temperature) | ||
|
||
def contact(update): | ||
update.message.replay_text("More about Tim: https://t1ms22.github.io") | ||
|
||
updater = telegram.ext.updater(TOKEN) | ||
disp = updater.dispatcher | ||
|
||
disp.add_handler(telegram.ext.CommandHandler("start", start)) | ||
disp.add_handler(telegram.ext.CommandHandler("help ", help)) | ||
disp.add_handler(telegram.ext.CommandHandler("temp", temp)) | ||
disp.add_handler(telegram.ext.CommandHandler("contact", contact)) | ||
|
||
updater.start_polling() | ||
updater.idle() |