Skip to content

Commit

Permalink
chore: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogério Munhoz committed Jul 3, 2023
1 parent a42ccb9 commit 356010b
Show file tree
Hide file tree
Showing 24 changed files with 343 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
deno 1.29.2
deno 1.34.3
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"typescript.tsdk": "node_modules/typescript/lib",
"deno.enable": true,
"deno.unstable": true
}
}
35 changes: 14 additions & 21 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
{
"importMap": "import-map.json",
"tasks": {
"polling": "deno run -A --watch polling.ts",
"server": "deno run -A server.ts",
"quality": "deno lint && deno fmt && deno check polling.ts && deno check server.ts"
},
"lint": {
"files": {
"exclude": [
"dist",
"node_modules",
"sessions",
".vercel"
]
}
"exclude": [
"dist",
"node_modules",
"sessions",
".vercel"
]
},
"fmt": {
"options": {
"lineWidth": 120
},
"files": {
"exclude": [
"dist",
"node_modules",
"sessions",
".vercel"
]
}
"lineWidth": 120,
"exclude": [
"dist",
"node_modules",
"sessions",
".vercel"
]
}
}
}
414 changes: 280 additions & 134 deletions deno.lock

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions import-map.json

This file was deleted.

4 changes: 2 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { serve } from "sift";
import { serve } from "./src/deps.ts";

import { handleUpdate } from "./src/endpoints/bot.ts";
import { setWebhook } from "./src/endpoints/setWebhook.ts";
import { getQRCode } from "./src/endpoints/qrcode.ts";
import { setWebhook } from "./src/endpoints/setWebhook.ts";

serve({
"/bot": handleUpdate,
Expand Down
14 changes: 10 additions & 4 deletions src/bot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { type ConversationFlavor, conversations as grammyConversations } from "grammy_conversations";
import { FileAdapter } from "grammy_storages";
import { Bot, Context, session, SessionFlavor } from "grammy";
import { MongoClient } from "mongo";
import {
Bot,
Context,
type ConversationFlavor,
conversations as grammyConversations,
FileAdapter,
MongoClient,
session,
SessionFlavor,
} from "./deps.ts";

import * as commands from "./commands.ts";
import { AppConfig } from "./config.ts";
Expand Down
4 changes: 2 additions & 2 deletions src/commands/getInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @deno-types="common-tags"
import { safeHtml, stripIndents } from "common-tags";
// @deno-types="https://esm.sh/common-tags@1.8.2"
import { safeHtml, stripIndents } from "../deps.ts";
import { Command } from "../domain/Command.ts";

export const getInfo: Command = {
Expand Down
6 changes: 2 additions & 4 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// @deno-types="common-tags"
import { stripIndents } from "common-tags";
import { InlineKeyboard } from "grammy";
import { AppContext, AppSession } from "../bot.ts";
import { evaluateQuery } from "../util/query.ts";
import { InlineKeyboard, stripIndents } from "../deps.ts";
import { BRL } from "../util/currency.ts";
import { evaluateQuery } from "../util/query.ts";

const KNOWN_MESSAGE = (user: AppSession) =>
stripIndents`
Expand Down
7 changes: 2 additions & 5 deletions src/conversations/set-info.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// @deno-types="common-tags"
import { oneLine, safeHtml, stripIndents } from "common-tags";
import { Conversation, createConversation } from "grammy_conversations";
import { InlineKeyboard } from "grammy";
import { AppContext } from "../bot.ts";
import { evaluateQuery } from "../util/query.ts";
import { Conversation, createConversation, InlineKeyboard, oneLine, safeHtml, stripIndents } from "../deps.ts";
import { BRL } from "../util/currency.ts";
import { evaluateQuery } from "../util/query.ts";

const PRIVACY_URL = "https://github.com/roziscoding/amandapix-telegram-bot/blob/main/PRIVACY.md";

Expand Down
3 changes: 1 addition & 2 deletions src/conversations/stop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Conversation, createConversation } from "grammy_conversations";
import { InlineKeyboard } from "grammy";
import { AppContext } from "../bot.ts";
import { Conversation, createConversation, InlineKeyboard } from "../deps.ts";

const stop = async (
conversation: Conversation<AppContext>,
Expand Down
12 changes: 12 additions & 0 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export * from "https://esm.sh/[email protected]";
export { evaluate, round } from "https://esm.sh/[email protected]";
export * from "https://lib.deno.dev/[email protected]/encoding/base64.ts";
export * from "https://lib.deno.dev/x/grammy@v1/mod.ts";
export { conversations, createConversation } from "https://lib.deno.dev/x/grammy_conversations@v1/mod.ts";
export type { Conversation, ConversationFlavor } from "https://lib.deno.dev/x/grammy_conversations@v1/mod.ts";
export * from "https://lib.deno.dev/x/grammy_storages@v2/file/src/mod.ts";
export { Collection, MongoClient } from "https://lib.deno.dev/x/[email protected]/mod.ts";
export * from "https://lib.deno.dev/x/pix@v2/mod.ts";
export { json, serve } from "https://lib.deno.dev/x/[email protected]/mod.ts";
export * from "https://lib.deno.dev/x/zod@v3/mod.ts";
export * from "https://raw.githubusercontent.com/denorg/qrcode/87101e061a7b1f9f9d5ddb304ca8c9e99262e9e1/mod.ts";
2 changes: 1 addition & 1 deletion src/endpoints/bot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { webhookCallback } from "grammy";
import { getBot } from "../bot.ts";
import { config } from "../config.ts";
import { webhookCallback } from "../deps.ts";

export const handleUpdate = webhookCallback(await getBot(config), "std/http", {
secretToken: config.telegram.secret,
Expand Down
4 changes: 1 addition & 3 deletions src/endpoints/qrcode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { decode } from "base64";
import { qrcode } from "qrcode";
import { json } from "sift";
import { decode, json, qrcode } from "../deps.ts";

function createQrCode(content: string) {
return qrcode(content)
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/setWebhook.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Api } from "grammy";
import { config } from "../config.ts";
import { Api } from "../deps.ts";

export async function setWebhook() {
const api = new Api(config.telegram.token);
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/done.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Bot } from "grammy";
import { AppContext } from "../bot.ts";
import { Bot } from "../deps.ts";
import { BRL } from "../util/currency.ts";

export function install(bot: Bot<AppContext>) {
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/registered.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BRL } from "../util/currency.ts";
import { Bot, InlineKeyboard } from "grammy";
import { AppContext } from "../bot.ts";
import { Bot, InlineKeyboard } from "../deps.ts";
import { BRL } from "../util/currency.ts";
import { getPixCodeForUser } from "../util/pix-code.ts";
import { evaluateQuery } from "../util/query.ts";

Expand Down
5 changes: 2 additions & 3 deletions src/handlers/unregistered.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Bot } from "grammy";
import { AppContext } from "../bot.ts";
import { Bot } from "../deps.ts";

export function install(bot: Bot<AppContext>) {
bot
.filter((ctx) => !ctx.session.pixKey)
.inlineQuery(/[\d.,]+/gi, (ctx) =>
ctx.answerInlineQuery([], {
switch_pm_text: "Clique aqui pra se cadastrar",
switch_pm_parameter: ctx.inlineQuery.query,
button: { text: "Clique aqui pra se cadastrar", start_parameter: ctx.inlineQuery.query },
cache_time: 0,
}));
}
2 changes: 1 addition & 1 deletion src/util/currency.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "../deps.ts";

export class CurrencyNotFoundError extends Error {
public readonly currency: string;
Expand Down
2 changes: 1 addition & 1 deletion src/util/pix-code.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pix } from "pix";
import { AppSession } from "../bot.ts";
import { pix } from "../deps.ts";

const normalize = (value: string) => value.normalize("NFD").replace(/\p{Diacritic}/gu, "");

Expand Down
2 changes: 1 addition & 1 deletion src/util/qr-code-url.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Context, MiddlewareFn } from "grammy";
import { AppConfig } from "../config.ts";
import type { Context, MiddlewareFn } from "../deps.ts";

export type QRCodeUrlContext = Context & {
getQrCodeUrl: (pixCode: string) => string;
Expand Down
4 changes: 2 additions & 2 deletions src/util/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { evaluate, round } from "mathjs";
import { evaluate, round } from "../deps.ts";
import { CurrencyConverstionRates, getConversionRates } from "./currency.ts";

export async function evaluateQuery(
Expand All @@ -17,7 +17,7 @@ export async function evaluateQuery(
readonly originalQuery: string;
}
> {
const replacedQuery = query.replace(/\,/ig, '.');
const replacedQuery = query.replace(/\,/ig, ".");
const values = extractCurrencies(replacedQuery);

if (!values.length) {
Expand Down
3 changes: 1 addition & 2 deletions src/util/storage-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { StorageAdapter } from "grammy";
import type { Collection } from "mongo";
import type { Collection, StorageAdapter } from "../deps.ts";

export interface ISession {
_id: { $oid: string };
Expand Down
4 changes: 2 additions & 2 deletions src/util/strings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @deno-types="common-tags"
import { stripIndents } from "common-tags";
// @deno-types="https://esm.sh/common-tags@1.8.2"
import { stripIndents } from "../deps.ts";

export const REPO_URL = "https://github.com/roziscoding/amandapix-telegram-bot";
export const PRIVACY_POLICY_URL = `${REPO_URL}/blob/main/PRIVACY.md`;
Expand Down

0 comments on commit 356010b

Please sign in to comment.