Telegram
Occult API destekli astroloji yorumları sunan bir Telegram botu oluşturun.
Bot kurulumu
Telegram'da BotFather'ı açın, /newbot ile bir bot oluşturun ve API token'ını kopyalayın. Bunu TELEGRAM_TOKEN ortam değişkeni olarak tanımlayın.
Python örneği
Komutları işlemek ve Occult API'yi çağırmak için python-telegram-bot kullanın:
from telegram import Update
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
import requests, os
async def horoscope(update: Update, context: ContextTypes.DEFAULT_TYPE):
sign = context.args[0] if context.args else 'aries'
response = requests.post(
f'https://api.occultapi.com/api/astro/rashifal/daily/',
headers={'X-API-Key': os.environ['OCCULT_API_KEY'], 'Content-Type': 'application/json'},
json={'rashi': sign},
)
data = response.json()
await update.message.reply_text(data['data']['get_daily_rashifal']['general_prediction'])
app = ApplicationBuilder().token(os.environ['TELEGRAM_TOKEN']).build()
app.add_handler(CommandHandler('horoscope', horoscope))
app.run_polling()Komutlar
Kullanıcıların menüde görmesi için bu komutları BotFather'a kaydedin:
/horoscope aries— günlük burç yorumu/panchang— bugünün panchang'ı/natal— doğum haritası sorgusu