This file contains hidden or 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
// @see https://github.com/denoland/deno/blob/main/cli/tests/unit_node/crypto/crypto_hash_test.ts#L17 | |
export * as crypto from 'node:crypto'; |
This file contains hidden or 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
// I'm using deno | |
import "https://deno.land/[email protected]/dotenv/load.ts"; | |
import { green } from "https://deno.land/[email protected]/fmt/colors.ts"; | |
import { itemsMenu } from './menus/example.menu.ts'; | |
const grammy = new Bot<GrammyContext>(Deno.env.get("BOT_TOKEN")||""); // replace `BOT_TOKEN` inside `.env` file with your own telegram bot's token | |
// attaching the menu to bot to get it to work if not we'll get the following errors inside the terminal | |
// `Error: Cannot send menu 'bot-items-menu'! Did you forget to use bot.use() for it?` |
This file contains hidden or 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
import { Bot, Context } from "grammy"; | |
export const bot = new Bot<Context>(process.env.TELEGRAM_BOT_TOKEN ?? ""); |
This file contains hidden or 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
<html | |
lang="en" | |
style="--tg-viewport-height: 100vh; --tg-viewport-stable-height: 100vh" | |
> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<script | |
src="/_frsh/refresh.js" | |
nonce="1734e1df1f3e44caaee66e087bc657e6" |
This file contains hidden or 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
import config from "$config/mod.ts"; | |
import { | |
initializeAgentExecutorWithOptions, | |
} from "langchain/agents"; | |
import { BaseLanguageModel } from "langchain/base_language"; | |
import { CallbackManager, ConsoleCallbackHandler } from "langchain/callbacks"; | |
import { ChatOpenAI } from "langchain/chat_models/openai"; | |
import { Calculator } from "langchain/tools/calculator"; | |
import { BaseChatMessage } from "langchain/schema"; | |
import { assert } from "asserts"; |
This file contains hidden or 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
import { Redis } from "https://deno.land/x/[email protected]/mod.ts"; | |
import { StorageAdapter } from "~grammy/deps.ts"; | |
/** | |
* A storage adapter that uses upstash redis. | |
* @template T The type of the data to store. | |
* | |
* Implementation of StorageAdapter v2 were inspired by @grammyjs/storage-cloudflare | |
* @see {@link "https://github.com/grammyjs/storages/blob/main/packages/cloudflare/src/kv.ts"} | |
*/ |
This file contains hidden or 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
When i hover `chatMembers`, i get: | |
``` | |
Argument of type 'Composer<ChatMembersContext>' is not assignable to parameter of type 'Middleware<GrammyContext>'. | |
Type 'Composer<ChatMembersContext>' is not assignable to type 'MiddlewareObj<GrammyContext>'. | |
The types returned by 'middleware()' are incompatible between these types. | |
Type 'MiddlewareFn<ChatMembersContext>' is not assignable to type 'MiddlewareFn<GrammyContext>'. | |
Types of parameters 'ctx' and 'ctx' are incompatible. | |
Type 'GrammyContext' is not assignable to type 'ChatMembersContext'. | |
Type 'SessionFlavor<GrammySession> & { conversation: ConversationControls; } & SessionFlavor<ConversationSessionData> & ChatMembersFlavor & Context & { ...; }' is not assignable to type 'ChatMembersContext'. | |
Type 'SessionFlavor<GrammySession> & { conversation: ConversationControls; } & SessionFlavor<ConversationSessionData> & ChatMembersFlavor & Context & { ...; }' is not assignable to type 'Context'. |
This file contains hidden or 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
When i hover `chatMembers`, i get: | |
``` | |
Argument of type 'Composer<ChatMembersContext>' is not assignable to parameter of type 'Middleware<GrammyContext>'. | |
Type 'Composer<ChatMembersContext>' is not assignable to type 'MiddlewareObj<GrammyContext>'. | |
The types returned by 'middleware()' are incompatible between these types. | |
Type 'MiddlewareFn<ChatMembersContext>' is not assignable to type 'MiddlewareFn<GrammyContext>'. | |
Types of parameters 'ctx' and 'ctx' are incompatible. | |
Type 'GrammyContext' is not assignable to type 'ChatMembersContext'. | |
Type 'SessionFlavor<GrammySession> & { conversation: ConversationControls; } & SessionFlavor<ConversationSessionData> & ChatMembersFlavor & Context & { ...; }' is not assignable to type 'ChatMembersContext'. | |
Type 'SessionFlavor<GrammySession> & { conversation: ConversationControls; } & SessionFlavor<ConversationSessionData> & ChatMembersFlavor & Context & { ...; }' is not assignable to type 'Context'. |
This file contains hidden or 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
// The code below works for both gramjs in node and grm in deno | |
.... // other imports above | |
import ChannelParticipants = Api.channels.ChannelParticipants; | |
import ChatParticipant = Api.ChatParticipant; | |
import ChannelParticipant = Api.ChannelParticipant; | |
This file contains hidden or 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
// pages/Upload.tsx | |
import { getPresignedUrl } from "~/utils/files"; | |
export default function Upload() { | |
const uploadPhoto = async (e: React.ChangeEvent<HTMLInputElement>) => { | |
const file = e.target.files?.[0]; | |
const name = encodeURIComponent(file?.name as string); | |
const type = encodeURIComponent(file?.type as string); | |
const res = await getPresignedUrl({ name, type, size: "" + file!.size }); |