Skip to content

Commit

Permalink
☄ Update grammy and grammy_types
Browse files Browse the repository at this point in the history
  • Loading branch information
Rnbsov committed Mar 9, 2024
1 parent 75a6e9c commit 8160869
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 82 deletions.
10 changes: 2 additions & 8 deletions bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Bot,
GrammyError,
HttpError,
} from 'https://deno.land/x/grammy@v1.20.3/mod.ts'
} from 'https://deno.land/x/grammy@v1.21.1/mod.ts'
import { createConversation } from 'https://deno.land/x/[email protected]/conversation.ts'
import { conversations } from 'https://deno.land/x/[email protected]/mod.ts'
import {
Expand Down Expand Up @@ -50,17 +50,11 @@ bot.use(slashCommandsListener)

// handlers
bot.on('message:entities:url', async ctx => {
const source = ctx.msg?.forward_origin
const message = ctx.message.text

// retrieve stuff from session
const token = ctx.session.apiToken
const defaultLabel = ctx.session.defaultLabel
const includeSource = ctx.session.includeSource

const api = new OmnivoreApi(token)

const {url, labels} = getUrlAndLabels(message, source, includeSource, defaultLabel)
const {url, labels} = getUrlAndLabels(ctx)

await api.saveUrl(url, labels)

Expand Down
100 changes: 34 additions & 66 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/inlineQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Composer } from 'https://deno.land/x/grammy@v1.20.3/mod.ts'
import { Composer } from 'https://deno.land/x/grammy@v1.21.1/mod.ts'
import { OmnivoreApi } from './omnivore/api.ts'
import { MyContext } from './sessionsHandler.ts'

Expand Down
2 changes: 1 addition & 1 deletion src/keyboards.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Keyboard } from 'https://deno.land/x/grammy@v1.20.3/mod.ts'
import { Keyboard } from 'https://deno.land/x/grammy@v1.21.1/mod.ts'

export const mainKeyboardLayout = new Keyboard()
.text('👾 Save a bunch of urls')
Expand Down
2 changes: 1 addition & 1 deletion src/omnivore/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
graphqlEndpoint,
searchQuery,
} from './graphql.ts'
import { InlineQueryResultBuilder } from 'https://deno.land/x/grammy@v1.20.3/mod.ts'
import { InlineQueryResultBuilder } from 'https://deno.land/x/grammy@v1.21.1/mod.ts'
import { Label, ProcessUrlsParams } from "../types.ts";

interface OmnivoreApiInterface {
Expand Down
2 changes: 1 addition & 1 deletion src/sessionsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Context,
session,
SessionFlavor,
} from 'https://deno.land/x/grammy@v1.20.3/mod.ts'
} from 'https://deno.land/x/grammy@v1.21.1/mod.ts'
import { createClient } from 'https://esm.sh/@supabase/[email protected]'
import { supabaseAdapter } from 'https://deno.land/x/[email protected]/supabase/src/mod.ts'
import { load } from 'https://deno.land/[email protected]/dotenv/mod.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/slashCommands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Composer } from 'https://deno.land/x/grammy@v1.20.3/mod.ts'
import { Composer } from 'https://deno.land/x/grammy@v1.21.1/mod.ts'
import { MyContext } from './sessionsHandler.ts'
import { cancelMenuAndResetLabel, includeSourceChoiceMenu } from "./menus.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/utils/getSourceLabel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageOrigin } from "https://deno.land/x/grammy_types@v3.4.6/message.ts";
import { MessageOrigin } from "https://deno.land/x/grammy_types@v3.5.2/message.ts";

export function getSourceLabel(source: MessageOrigin) {
let sourceLabel = { name: '' }
Expand Down
13 changes: 11 additions & 2 deletions src/utils/getUrlAndLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ import { getDefaultLabel } from "./getDefaultLabel.ts";
import { parseUrls } from "./parseUrls.ts";
import { startsWithUrl } from "./startsWithUrl.ts";
import { Label } from '../types.ts'
import { MessageOrigin } from "https://deno.land/x/[email protected]/message.ts";
import { type Filter } from "https://deno.land/x/[email protected]/mod.ts"
import { MyContext } from '../sessionsHandler.ts'

export function getUrlAndLabels(message: string, source: MessageOrigin | undefined, sessionIncludeSource: boolean, sessionDefaultLabel: string) {
export function getUrlAndLabels(ctx: Filter<MyContext, 'message:entities:url'>) {
let url, labels: Label[]

// retrieving information from ctx
const message = ctx.message.text
const source = ctx.msg?.forward_origin

// retrieving information from session
const sessionIncludeSource = ctx.session.includeSource
const sessionDefaultLabel = ctx.session.defaultLabel

// parse url from the message
if (startsWithUrl(message)) {
Expand Down

0 comments on commit 8160869

Please sign in to comment.