Skip to content

Instantly share code, notes, and snippets.

View SaDi-BRo's full-sized avatar
🔇
Trying

SaDi SaDi-BRo

🔇
Trying
View GitHub Profile
@SaDi-BRo
SaDi-BRo / openai.ts
Last active March 6, 2023 19:16
The code shows you how to fetch a data from OpenAI
const fetchOpenAI = async (text: string) => {
const response = await fetch('https://api.openai.com/v1/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${Deno.env.get('OPENAI_KEY')}`,
},
body: JSON.stringify({
model: 'text-davinci-003',
prompt: text,
@SaDi-BRo
SaDi-BRo / webhook.ts
Last active September 4, 2022 14:58
This is about how to do webhook on deno grammy.
import { Bot, webhookCallback } from 'https://deno.land/x/grammy@v1.11.0/mod.ts';
import { serve } from 'https://deno.land/std@0.154.0/http/server.ts';
import 'https://deno.land/x/dotenv@v3.2.0/load.ts';
const bot = new Bot(Deno.env.get('BOT_TOKEN')!);
const handleUpdate = webhookCallback(bot, 'std/http');
bot.on('message', (ctx) => ctx.reply('Hi there!'));
serve(async (req) => {