{"id":235,"title":"Telegram ile PC Y\u00f6netimi: Kendi Botunuzu Geli\u015ftirin","content":"<p>Telegram, sadece bir mesajla\u015fma uygulamas\u0131 olman\u0131n \u00f6tesinde, sundu\u011fu Bot API'si ile bir\u00e7ok otomasyon i\u015flemini kolayca ger\u00e7ekle\u015ftirebilece\u011finiz bir platform haline geldi. Bu makalede, Telegram \u00fczerinden bilgisayar\u0131n\u0131z\u0131 y\u00f6netebilece\u011finiz bir botun nas\u0131l geli\u015ftirilece\u011fini ad\u0131m ad\u0131m anlataca\u011f\u0131m. Bu bot sayesinde bilgisayar\u0131n\u0131z\u0131 uzaktan kapatabilir, yeniden ba\u015flatabilir, ekran g\u00f6r\u00fcnt\u00fcs\u00fc alabilir ve hatta kameradan g\u00f6r\u00fcnt\u00fc elde edebilirsiniz. Hadi ba\u015flayal\u0131m!<\/p><p>---<\/p><p>## **Neler Yapaca\u011f\u0131z?**<\/p><p>Bu projede, Python programlama dili ve Telegram Bot API'si kullanarak a\u015fa\u011f\u0131daki \u00f6zelliklere sahip bir bot geli\u015ftirece\u011fiz:<\/p><p>1. **Bilgisayar\u0131 Kapatma\/Yeniden Ba\u015flatma**: Bilgisayar\u0131n\u0131z\u0131 uzaktan kapatabilir veya yeniden ba\u015flatabilirsiniz.<br>2. **Ekran G\u00f6r\u00fcnt\u00fcs\u00fc Alma**: Bilgisayar\u0131n\u0131z\u0131n ekran g\u00f6r\u00fcnt\u00fcs\u00fcn\u00fc al\u0131p Telegram \u00fczerinden g\u00f6nderebilirsiniz.<br>3. **Kameradan G\u00f6r\u00fcnt\u00fc Alma**: Bilgisayar\u0131n\u0131z\u0131n kameras\u0131n\u0131 a\u00e7arak g\u00f6r\u00fcnt\u00fc alabilirsiniz.<br>4. **Komut \u00c7al\u0131\u015ft\u0131rma**: Bilgisayarda komut sat\u0131r\u0131 komutlar\u0131n\u0131 \u00e7al\u0131\u015ft\u0131rabilirsiniz.<\/p><p>---<\/p><p>## **Gereksinimler**<\/p><p>Projeyi geli\u015ftirmek i\u00e7in a\u015fa\u011f\u0131daki ara\u00e7lara ihtiyac\u0131n\u0131z olacak:<\/p><p>1. **Python** (3.6 veya \u00fczeri)<br>2. **Telegram Bot API** (BotFather ile bot olu\u015fturulacak)<br>3. **Gerekli Python K\u00fct\u00fcphaneleri**:<br>&nbsp; ```bash<br>&nbsp; pip install python-telegram-bot pyautogui opencv-python<br>&nbsp; ```<\/p><p>---<\/p><p>## **1. Telegram Bot Olu\u015fturma**<\/p><p>\u0130lk ad\u0131m, Telegram \u00fczerinde bir bot olu\u015fturmak. Bunun i\u00e7in:<\/p><p>1. Telegram'da **BotFather**'\u0131 aray\u0131n ve ba\u015flat\u0131n.<br>2. `\/newbot` komutunu g\u00f6nderin.<br>3. Botunuz i\u00e7in bir ad ve kullan\u0131c\u0131 ad\u0131 belirleyin.<br>4. BotFather size bir **API Token** verecek. Bu token'i kaydedin, \u00e7\u00fcnk\u00fc botunuzu y\u00f6netmek i\u00e7in gerekecek.<\/p><p>---<\/p><p>## **2. Proje Yap\u0131s\u0131**<\/p><p>Botumuz, a\u015fa\u011f\u0131daki bile\u015fenlerden olu\u015facak:<\/p><p>- **Yetkilendirme Mekanizmas\u0131**: Sadece yetkili kullan\u0131c\u0131lar botu kullanabilecek.<br>- **Komutlar**: Bilgisayar\u0131 kapatma, ekran g\u00f6r\u00fcnt\u00fcs\u00fc alma gibi i\u015flevler.<br>- **G\u00fcvenlik**: Yetkisiz eri\u015fimi engellemek i\u00e7in \u00f6nlemler.<\/p><p>---<\/p><p>## **3. Kodun Ad\u0131m Ad\u0131m A\u00e7\u0131klanmas\u0131**<\/p><p>### **a. Gerekli K\u00fct\u00fcphanelerin \u0130\u00e7e Aktar\u0131lmas\u0131**<\/p><p>\u00d6ncelikle, projemiz i\u00e7in gerekli k\u00fct\u00fcphaneleri i\u00e7e aktar\u0131yoruz:<\/p><p>```python<br>import os<br>import subprocess<br>import logging<br>import pyautogui<br>import cv2<br>from telegram import Update<br>from telegram.ext import Application, CommandHandler, ContextTypes<br>```<\/p><p>### **b. Yetkilendirme Mekanizmas\u0131**<\/p><p>Botun sadece belirli kullan\u0131c\u0131lar taraf\u0131ndan kullan\u0131lmas\u0131n\u0131 sa\u011flamak i\u00e7in bir yetkilendirme mekanizmas\u0131 ekliyoruz:<\/p><p>```python<br>AUTHORIZED_USER_IDS = &nbsp;# Yetkili kullan\u0131c\u0131 ID'leri<\/p><p>def is_authorized(update: Update):<br>&nbsp; &nbsp;return update.message.from_user.id in AUTHORIZED_USER_IDS<br>```<\/p><p>### **c. Bot Komutlar\u0131**<\/p><p>Botun temel komutlar\u0131n\u0131 tan\u0131ml\u0131yoruz:<\/p><p>#### **\/start**: Botu ba\u015flat\u0131r.<br>```python<br>async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):<br>&nbsp; &nbsp;await update.message.reply_text(\"Merhaba! PC y\u00f6netim botuna ho\u015f geldiniz.\")<br>```<\/p><p>#### **\/shutdown**: Bilgisayar\u0131 kapat\u0131r.<br>```python<br>async def shutdown(update: Update, context: ContextTypes.DEFAULT_TYPE):<br>&nbsp; &nbsp;if is_authorized(update):<br>&nbsp; &nbsp; &nbsp; &nbsp;await update.message.reply_text(\"Bilgisayar kapat\u0131l\u0131yor...\")<br>&nbsp; &nbsp; &nbsp; &nbsp;os.system(\"shutdown \/s \/t 1\")<br>&nbsp; &nbsp;else:<br>&nbsp; &nbsp; &nbsp; &nbsp;await update.message.reply_text(\"Yetkiniz yok.\")<br>```<\/p><p>#### **\/screenshot**: Ekran g\u00f6r\u00fcnt\u00fcs\u00fc al\u0131r.<br>```python<br>async def screenshot(update: Update, context: ContextTypes.DEFAULT_TYPE):<br>&nbsp; &nbsp;if is_authorized(update):<br>&nbsp; &nbsp; &nbsp; &nbsp;screenshot = pyautogui.screenshot()<br>&nbsp; &nbsp; &nbsp; &nbsp;screenshot.save(\"screenshot.png\")<br>&nbsp; &nbsp; &nbsp; &nbsp;await update.message.reply_photo(photo=open(\"screenshot.png\", \"rb\"))<br>&nbsp; &nbsp;else:<br>&nbsp; &nbsp; &nbsp; &nbsp;await update.message.reply_text(\"Yetkiniz yok.\")<br>```<\/p><p>#### **\/webcam**: Kameradan g\u00f6r\u00fcnt\u00fc al\u0131r.<br>```python<br>async def webcam(update: Update, context: ContextTypes.DEFAULT_TYPE):<br>&nbsp; &nbsp;if is_authorized(update):<br>&nbsp; &nbsp; &nbsp; &nbsp;cap = cv2.VideoCapture(0)<br>&nbsp; &nbsp; &nbsp; &nbsp;ret, frame = cap.read()<br>&nbsp; &nbsp; &nbsp; &nbsp;if ret:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cv2.imwrite(\"webcam.png\", frame)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;await update.message.reply_photo(photo=open(\"webcam.png\", \"rb\"))<br>&nbsp; &nbsp; &nbsp; &nbsp;cap.release()<br>&nbsp; &nbsp;else:<br>&nbsp; &nbsp; &nbsp; &nbsp;await update.message.reply_text(\"Yetkiniz yok.\")<br>```<\/p><p>#### **\/cmd**: Komut \u00e7al\u0131\u015ft\u0131r\u0131r.<br>```python<br>async def cmd(update: Update, context: ContextTypes.DEFAULT_TYPE):<br>&nbsp; &nbsp;if is_authorized(update):<br>&nbsp; &nbsp; &nbsp; &nbsp;command = \" \".join(context.args)<br>&nbsp; &nbsp; &nbsp; &nbsp;result = subprocess.run(command, shell=True, capture_output=True, text=True)<br>&nbsp; &nbsp; &nbsp; &nbsp;await update.message.reply_text(f\"Komut \u00e7\u0131kt\u0131s\u0131:\\n{result.stdout}\")<br>&nbsp; &nbsp;else:<br>&nbsp; &nbsp; &nbsp; &nbsp;await update.message.reply_text(\"Yetkiniz yok.\")<br>```<\/p><p>### **d. Botu Ba\u015flatma**<\/p><p>Son olarak, botu ba\u015flat\u0131yoruz:<\/p><p>```python<br>def main():<br>&nbsp; &nbsp;application = Application.builder().token(\"YOUR_TELEGRAM_BOT_TOKEN\").build()<\/p><p>&nbsp; &nbsp;# Komutlar<br>&nbsp; &nbsp;application.add_handler(CommandHandler(\"start\", start))<br>&nbsp; &nbsp;application.add_handler(CommandHandler(\"shutdown\", shutdown))<br>&nbsp; &nbsp;application.add_handler(CommandHandler(\"screenshot\", screenshot))<br>&nbsp; &nbsp;application.add_handler(CommandHandler(\"webcam\", webcam))<br>&nbsp; &nbsp;application.add_handler(CommandHandler(\"cmd\", cmd))<\/p><p>&nbsp; &nbsp;# Botu ba\u015flat<br>&nbsp; &nbsp;application.run_polling()<\/p><p>if __name__ == \"__main__\":<br>&nbsp; &nbsp;main()<br>```<\/p><p>---<\/p><p>## **4. Botu \u00c7al\u0131\u015ft\u0131rma**<\/p><p>1. Kodu bir Python dosyas\u0131na kaydedin (\u00f6rne\u011fin, `pc_bot.py`).<br>2. Terminalde dosyay\u0131 \u00e7al\u0131\u015ft\u0131r\u0131n:<br>&nbsp; ```bash<br>&nbsp; python pc_bot.py<br>&nbsp; ```<br>3. Telegram'da botunuzu ba\u015flat\u0131n ve komutlar\u0131 kullan\u0131n.<\/p><p>---<\/p><blockquote><p>import os<\/p><p>import subprocess<\/p><p>import logging<\/p><p>import pyautogui<\/p><p>import cv2<\/p><p>from telegram import Update<\/p><p>from telegram.ext import Application, CommandHandler, ContextTypes<\/p><p><br>&nbsp;<\/p><p># Telegram Bot Token<\/p><p>TOKEN = \"*******************\"<\/p><p><br>&nbsp;<\/p><p># Yetkili kullan\u0131c\u0131 ID'leri<\/p><p>AUTHORIZED_USER_IDS = &nbsp;# Buraya kendi Telegram ID'nizi yaz\u0131n<\/p><p><br>&nbsp;<\/p><p># Loglama ayarlar\u0131<\/p><p>logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)<\/p><p>logger = logging.getLogger(__name__)<\/p><p><br>&nbsp;<\/p><p># Yetki kontrol\u00fc<\/p><p>def is_authorized(update: Update):<\/p><p>&nbsp; &nbsp; return update.message.from_user.id in AUTHORIZED_USER_IDS<\/p><p><br>&nbsp;<\/p><p># \/start komutu<\/p><p>async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):<\/p><p>&nbsp; &nbsp; await update.message.reply_text(\"Merhaba! PC y\u00f6netim botuna ho\u015f geldiniz.\")<\/p><p><br>&nbsp;<\/p><p># \/shutdown komutu<\/p><p>async def shutdown(update: Update, context: ContextTypes.DEFAULT_TYPE):<\/p><p>&nbsp; &nbsp; if is_authorized(update):<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_text(\"Bilgisayar kapat\u0131l\u0131yor...\")<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; os.system(\"shutdown \/s \/t 1\")<\/p><p>&nbsp; &nbsp; else:<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_text(\"Yetkiniz yok.\")<\/p><p><br>&nbsp;<\/p><p># \/restart komutu<\/p><p>async def restart(update: Update, context: ContextTypes.DEFAULT_TYPE):<\/p><p>&nbsp; &nbsp; if is_authorized(update):<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_text(\"Bilgisayar yeniden ba\u015flat\u0131l\u0131yor...\")<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; os.system(\"shutdown \/r \/t 1\")<\/p><p>&nbsp; &nbsp; else:<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_text(\"Yetkiniz yok.\")<\/p><p><br>&nbsp;<\/p><p># \/screenshot komutu<\/p><p>async def screenshot(update: Update, context: ContextTypes.DEFAULT_TYPE):<\/p><p>&nbsp; &nbsp; if is_authorized(update):<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; screenshot = pyautogui.screenshot()<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; screenshot.save(\"screenshot.png\")<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_photo(photo=open(\"screenshot.png\", \"rb\"))<\/p><p>&nbsp; &nbsp; else:<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_text(\"Yetkiniz yok.\")<\/p><p><br>&nbsp;<\/p><p># \/webcam komutu<\/p><p>async def webcam(update: Update, context: ContextTypes.DEFAULT_TYPE):<\/p><p>&nbsp; &nbsp; if is_authorized(update):<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; cap = cv2.VideoCapture(0)<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; ret, frame = cap.read()<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; if ret:<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cv2.imwrite(\"webcam.png\", frame)<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_photo(photo=open(\"webcam.png\", \"rb\"))<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; cap.release()<\/p><p>&nbsp; &nbsp; else:<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_text(\"Yetkiniz yok.\")<\/p><p><br>&nbsp;<\/p><p># \/cmd komutu (Komut \u00e7al\u0131\u015ft\u0131rma)<\/p><p>async def cmd(update: Update, context: ContextTypes.DEFAULT_TYPE):<\/p><p>&nbsp; &nbsp; if is_authorized(update):<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; command = \" \".join(context.args)<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; result = subprocess.run(command, shell=True, capture_output=True, text=True)<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_text(f\"Komut \u00e7\u0131kt\u0131s\u0131:\\n{result.stdout}\")<\/p><p>&nbsp; &nbsp; else:<\/p><p>&nbsp; &nbsp; &nbsp; &nbsp; await update.message.reply_text(\"Yetkiniz yok.\")<\/p><p><br>&nbsp;<\/p><p># Botu ba\u015flatma<\/p><p>def main():<\/p><p>&nbsp; &nbsp; application = Application.builder().token(TOKEN).build()<\/p><p><br>&nbsp;<\/p><p>&nbsp; &nbsp; # Komutlar<\/p><p>&nbsp; &nbsp; application.add_handler(CommandHandler(\"start\", start))<\/p><p>&nbsp; &nbsp; application.add_handler(CommandHandler(\"shutdown\", shutdown))<\/p><p>&nbsp; &nbsp; application.add_handler(CommandHandler(\"restart\", restart))<\/p><p>&nbsp; &nbsp; application.add_handler(CommandHandler(\"screenshot\", screenshot))<\/p><p>&nbsp; &nbsp; application.add_handler(CommandHandler(\"webcam\", webcam))<\/p><p>&nbsp; &nbsp; application.add_handler(CommandHandler(\"cmd\", cmd))<\/p><p><br>&nbsp;<\/p><p>&nbsp; &nbsp; # Botu ba\u015flat<\/p><p>&nbsp; &nbsp; application.run_polling()<\/p><p><br>&nbsp;<\/p><p>if __name__ == \"__main__\":<\/p><p>&nbsp; &nbsp; main()<\/p><\/blockquote><p>&nbsp;<\/p><p>--<\/p><p>## **5. G\u00fcvenlik \u00d6nerileri**<\/p><p>- **Bot Token'\u0131n\u0131 Koruyun**: Bot token'\u0131n\u0131z\u0131 asla payla\u015fmay\u0131n.<br>- **Yetkilendirme Mekanizmas\u0131**: Sadece yetkili kullan\u0131c\u0131lar\u0131n botu kullanmas\u0131na izin verin.<br>- **Hassas Komutlar\u0131 S\u0131n\u0131rland\u0131r\u0131n**: Bilgisayar\u0131 kapatma gibi hassas komutlar\u0131 sadece g\u00fcvendi\u011finiz kullan\u0131c\u0131lara a\u00e7\u0131n.<\/p><p>---<\/p><p>## **Sonu\u00e7**<\/p><p>Bu makalede, Telegram \u00fczerinden bilgisayar\u0131n\u0131z\u0131 y\u00f6netebilece\u011finiz bir botun nas\u0131l geli\u015ftirilece\u011fini ad\u0131m ad\u0131m anlatt\u0131k. Bu bot sayesinde bilgisayar\u0131n\u0131z\u0131 uzaktan kontrol edebilir ve \u00e7e\u015fitli i\u015flemler ger\u00e7ekle\u015ftirebilirsiniz. Projeyi geli\u015ftirerek daha fazla \u00f6zellik ekleyebilir ve kendi ihtiya\u00e7lar\u0131n\u0131za g\u00f6re \u00f6zelle\u015ftirebilirsiniz.<\/p><p>E\u011fer bu projeyi denerseniz, deneyimlerinizi yorumlarda payla\u015fmay\u0131 unutmay\u0131n. Bir sonraki makalede g\u00f6r\u00fc\u015fmek \u00fczere!<\/p><p>---<\/p><p>**Ek Kaynaklar:**<br>- (https:\/\/core.telegram.org\/bots\/api)<br>- (https:\/\/github.com\/python-telegram-bot\/python-telegram-bot)<br>- (https:\/\/docs.opencv.org\/)<br>- (https:\/\/pyautogui.readthedocs.io\/)<\/p><p>---<\/p><p>Umar\u0131m bu makale, okuyucular\u0131n\u0131z i\u00e7in faydal\u0131 olur! Ba\u015fka sorular\u0131n\u0131z varsa bana her zaman ula\u015fabilirsiniz. \ud83d\ude0a<\/p>","excerpt":"Telegram, sadece bir mesajla\u015fma uygulamas\u0131 olman\u0131n \u00f6tesinde, sundu\u011fu Bot API'si ile bir\u00e7ok otomasyon i\u015flemini kolayca ger\u00e7ekle\u015ftirebilece\u011finiz bir platform haline geldi. Bu makalede, Telegram \u00fczerinden bilgisayar\u0131n\u0131z\u0131 y\u00f6netebilece\u011finiz bir botun nas\u0131l geli\u015ftirilece\u011fini ad\u0131m ad\u0131m anlataca\u011f\u0131m. Bu bot sayesinde bilgisayar\u0131n\u0131z\u0131 uzaktan kapatabilir, yeniden ba\u015flatabilir, ekran g\u00f6r\u00fcnt\u00fcs\u00fc alabilir ve hatta kameradan g\u00f6r\u00fcnt\u00fc elde edebilirsiniz.","created_at":"2025-01-06 18:50:28","updated_at":"2026-09-07 15:40:38","category_id":9,"view_count":568,"reading_time":8,"status":"published","editor_choice":0,"is_editor_choice":0,"published_at":"2025-01-06 18:50:28","featured_image":"resimyok.jpg","slug":"telegram-ile-pc-yonetimi-kendi-botunuzu-gelistirin","category_name":"Yaz\u0131l\u0131m","category_slug":"yazilim"}