-
Notifications
You must be signed in to change notification settings - Fork 21
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
26 changed files
with
798 additions
and
3 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
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,3 +2,7 @@ | |
externals/ | ||
downloads/ | ||
test* | ||
<<<<<<< HEAD | ||
======= | ||
.log | ||
>>>>>>> main |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
{ | ||
<<<<<<< HEAD | ||
======= | ||
"deno.enable": true, | ||
>>>>>>> main | ||
"deno.importMap": "./import_map.json" | ||
} |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
<<<<<<< HEAD | ||
export const version = "0.0.8"; | ||
======= | ||
export const version = "0.1.6"; | ||
>>>>>>> main |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"importMap": "./import_map.json", | ||
"tasks": { | ||
"run": "deno run -A main.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<<<<<<< HEAD | ||
export { config } from "https://deno.land/x/[email protected]/mod.ts"; | ||
export { cleanEnv, num, str } from "https://deno.land/x/[email protected]/mod.ts"; | ||
export { html } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
@@ -11,3 +12,13 @@ export * from "https://deno.land/x/[email protected]/mod.ts"; | |
export * from "https://deno.land/x/[email protected]/src/client/uploads.ts"; | ||
export * from "https://deno.land/x/[email protected]/src/define.d.ts"; | ||
export { bigInt } from "https://deno.land/x/[email protected]/deps.ts"; | ||
======= | ||
// Internal dependencies | ||
export { | ||
cleanEnv, | ||
makeValidator, | ||
num, | ||
str, | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
export * from "https://deno.land/x/[email protected]/mod.ts"; | ||
>>>>>>> main |
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 |
---|---|---|
@@ -1,9 +1,46 @@ | ||
<<<<<<< HEAD | ||
import { cleanEnv, config, num, str } from "$deps"; | ||
|
||
config({ export: true }); | ||
======= | ||
import * as log from "std/log/mod.ts"; | ||
import { config } from "std/dotenv/mod.ts"; | ||
import { cleanEnv, makeValidator, num, str } from "./deps.ts"; | ||
|
||
await config({ export: true }); | ||
|
||
// https://stackoverflow.com/a/54256858/12250600 | ||
const PREFIX_REGEX = /^[^\p{L}\d\s@#\$]$/u; | ||
|
||
const cmdPrefix = makeValidator((input) => { | ||
if (PREFIX_REGEX.test(input)) { | ||
return input; | ||
} | ||
log.warning( | ||
"falling back to '\\' for COMMAND_PREFIX: a single symbol excluding @, # and $ was expected", | ||
); | ||
Deno.exit(); | ||
return "\\"; | ||
}); | ||
|
||
const inputPrefix = makeValidator((input) => { | ||
if (PREFIX_REGEX.test(input) && input !== Deno.env.get("COMMAND_PREFIX")) { | ||
return input; | ||
} | ||
log.warning( | ||
"falling back to '>' for INPUT_PREFIX: a single symbol excluding @, #, $ and COMMAND_PREFIX was expected", | ||
); | ||
return "\\"; | ||
}); | ||
>>>>>>> main | ||
|
||
export default cleanEnv(Deno.env.toObject(), { | ||
STRING_SESSION: str(), | ||
APP_ID: num(), | ||
APP_HASH: str(), | ||
<<<<<<< HEAD | ||
======= | ||
COMMAND_PREFIX: cmdPrefix({ default: "\\" }), | ||
INPUT_PREFIX: inputPrefix({ default: ">" }), | ||
>>>>>>> main | ||
}); |
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 |
---|---|---|
@@ -1,14 +1,32 @@ | ||
<<<<<<< HEAD | ||
import { events, TelegramClient } from "$grm"; | ||
|
||
export interface HandlerFuncParams { | ||
client: TelegramClient; | ||
event: events.NewMessageEvent; | ||
======= | ||
import { NewMessageEvent, TelegramClient } from "$grm"; | ||
|
||
export const End = Symbol(); | ||
|
||
export type HandleFuncResult = Promise<void | typeof End>; | ||
|
||
export interface HandlerFuncParams { | ||
client: TelegramClient; | ||
event: NewMessageEvent; | ||
>>>>>>> main | ||
} | ||
|
||
export abstract class Handler { | ||
abstract check( | ||
{ client, event }: HandlerFuncParams, | ||
): Promise<boolean> | boolean; | ||
|
||
<<<<<<< HEAD | ||
abstract handle({ client, event }: HandlerFuncParams): Promise<void>; | ||
======= | ||
abstract handle( | ||
{ client, event }: HandlerFuncParams, | ||
): HandleFuncResult; | ||
>>>>>>> main | ||
} |
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
{ | ||
"imports": { | ||
<<<<<<< HEAD | ||
"$deps": "./deps.ts", | ||
"$grm": "https://deno.land/x/[email protected]/mod.ts", | ||
"$grm/": "https://deno.land/x/[email protected]/" | ||
======= | ||
"$grm": "https://deno.land/x/[email protected]/mod.ts", | ||
"$grm-deps": "https://deno.land/x/[email protected]/deps.ts", | ||
"$xor": "./xor.ts", | ||
"std/": "https://deno.land/[email protected]/" | ||
>>>>>>> main | ||
} | ||
} |
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
Oops, something went wrong.