Skip to content

Commit

Permalink
Fix more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rojvv committed May 31, 2024
1 parent 7caebe8 commit b88fd73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
14 changes: 0 additions & 14 deletions islands/SessionStringAnalyzer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { encodeHex } from "$std/encoding/hex.ts";
import { ComponentChildren } from "preact";
import { signal, useSignalEffect } from "@preact/signals";

import { id, types } from "mtkruto/2_tl.ts";

import { Caption } from "../components/Caption.tsx";
import { Input } from "../components/Input.tsx";
import { Label } from "../components/Label.tsx";
Expand Down Expand Up @@ -107,18 +105,6 @@ export function SessionStringAnalyzer() {
);
}

const inputBotInlineMessageID_CTR = new types.InputBotInlineMessageID({
dc_id: 0,
id: 0n,
access_hash: 0n,
})[id];
const inputBotInlineMessageID64_CTR = new types.InputBotInlineMessageID64({
dc_id: 0,
owner_id: 0n,
id: 0,
access_hash: 0n,
})[id];

function Kv({ k, v, c }: { k: string; v: ComponentChildren; c?: string }) { // TODO: merge with FileIdAnalyzer's
return (
<div class={"flex flex-col gap-0.5 " + (c ?? "")}>
Expand Down
13 changes: 8 additions & 5 deletions islands/SessionStringGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { unreachable } from "$std/assert/unreachable.ts";
import { IS_BROWSER } from "$fresh/runtime.ts";
import { computed, Signal, signal } from "@preact/signals";

import { Client, StorageMemory, types } from "mtkruto/mod.ts";
import { Client, errors, StorageMemory } from "mtkruto/mod.ts";
import { getDcIps } from "mtkruto/transport/2_transport_provider.ts";

import { isValidLibrary, ValidLibrary } from "../lib/misc.ts";
Expand Down Expand Up @@ -191,8 +191,8 @@ export function SessionStringGenerator() {
onSubmit={(e) => {
e.preventDefault();
generate(library).catch((e) => {
if (e instanceof types.Rpc_error) {
displayError(e.error_message);
if (e instanceof errors.TelegramError) {
displayError(e.errorMessage);
} else {
displayError(e);
}
Expand Down Expand Up @@ -351,7 +351,10 @@ async function generateSessionString(library: ValidLibrary) { // TODO: report er
return;
}

const client = new Client(new StorageMemory(), apiId_, apiHash_, {
const client = new Client({
storage: new StorageMemory(),
apiId: apiId_,
apiHash: apiHash_,
deviceModel: navigator.userAgent.trim().split(" ")[0] || "Unknown",
initialDc: environment.value == "Test" ? "2-test" : undefined,
});
Expand All @@ -361,7 +364,7 @@ async function generateSessionString(library: ValidLibrary) { // TODO: report er
let firstPasswordAttempt_ = true;
const firstPasswordAttempt = signal(true);
await client.start(
accountType.value == "Bot" ? account_ : {
accountType.value == "Bot" ? { botToken: account_ } : {
phone: account_,
code: () =>
new Promise((resolve, reject) => {
Expand Down

0 comments on commit b88fd73

Please sign in to comment.