Skip to content

Commit

Permalink
Created Telegram bot to use Telegram API
Browse files Browse the repository at this point in the history
  • Loading branch information
HexagonNico committed Dec 15, 2022
1 parent 9e43f8e commit 6e2ca24
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
3 changes: 3 additions & 0 deletions code/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ npm-debug.*
*.orig.*
web-build/

# Private API Keys
api_keys.js

# External editors
.vscode/
.idea/
Expand Down
28 changes: 19 additions & 9 deletions code/components/Test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React, { useCallback } from "react";
import { Alert, Button, Linking, View } from "react-native";

//const API_TOKEN = '';
// TODO: I tried to make this work using .env but kept getting 'undefined'
import { TelegramApiKey } from "../api_keys";

// Button that can add an existing sticker pack to your telegram given the name of the pack. See examples below.
// This does not use Telegram API, but needs the pack to be uploaded on telegram.
const AddStickersButton = ({packName}: {packName: string}) => {
const url = 'https://telegram.me/addstickers/' + packName;
const onPress = useCallback(async() => {
Expand All @@ -18,20 +21,27 @@ const AddStickersButton = ({packName}: {packName: string}) => {
);
}

/*
// Uses the telegram api to get information about the bot
// TODO: Import stickers with https://core.telegram.org/api/stickers
const fetchAPI = () => {
return fetch('https://api.telegram.org/botTOKEN/getMe').then((response) => response.json()).then((json) => {
return fetch('https://api.telegram.org/bot' + TelegramApiKey + '/getMe').then((response) => response.json()).then((json) => {
console.log(json)
}).catch((error) => {
console.error(error);
});
};*/
};

// This is just a test
export const Test = () => (
<View style={{paddingTop: 300}}>
<AddStickersButton packName="NekoHD" />
<AddStickersButton packName="Kiritsu" />
<AddStickersButton packName="Kurolily" />
<AddStickersButton packName="thehuskies" />
<View>
<View style={{paddingTop: 100}}>
<AddStickersButton packName="NekoHD" />
<AddStickersButton packName="Kiritsu" />
<AddStickersButton packName="Kurolily" />
<AddStickersButton packName="thehuskies" />
</View>
<View style={{paddingTop: 100}}>
<Button title="Use API" onPress={fetchAPI} />
</View>
</View>
);

0 comments on commit 6e2ca24

Please sign in to comment.