-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
53 additions
and
82 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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) | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) { | ||
|