Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorpelSenf committed Mar 26, 2021
0 parents commit 9089b13
Show file tree
Hide file tree
Showing 32 changed files with 6,741 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"denoland.vscode-deno",
"editorconfig.editorconfig",
"davidanson.vscode-markdownlint",
"esbenp.prettier-vscode"
]
}
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch via npm",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["--inspect", "--allow-net", "index.ts"],
"port": 8001
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": { "source.fixAll": true },
"deno.enable": true
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 KnorpelSenf

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# **grammY** _—Telegram Bot Framework for Deno and Node_

## Features

- Super easy to learn
- Lightning fast
- Outstanding `TypeScript` support
- Full Telegram Bot API 5.1 support (with 100 % type coverage)
- Scales up when your bot does

## Quickstart

grammY was written for both Deno and Node.
You can write your bot with both `TypeScript` and `JavaScript`.

Choose your platform:

**[Deno](./deno)** (recommended)

**[Node](./node-backport)**

## Resources

grammY Documentation

grammY API Reference

Telegram Bot API Reference (Official)
8 changes: 8 additions & 0 deletions deno/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*]
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 80
7 changes: 7 additions & 0 deletions deno/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 4,
"semi": false,
"arrowParens": "avoid"
}
50 changes: 50 additions & 0 deletions deno/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# grammY for Deno

If you haven't already, install Deno.

```shellscript
curl -fsSL https://deno.land/x/install/install.sh | sh
```

## Quickstart

### Simple example

Talk to [@BotFather](https://t.me/BotFather) to create a new Telegram bot and obtain a _bot token_.

Paste the following code into a new file `example-bot.ts`.

```ts
import { Bot } from 'https://deno.land/x/grammy'

// Create bot
const bot = new Bot('<your-bot-token>')

// Listen for messages
bot.command('start', ctx => ctx.reply('Welcome! Send me your pics!'))
bot.on('message:photo' ctx => ctx.reply('Nice photo!'))

// Launch!
bot.launch()
```

**Congratulations!**
You have successfully created your first Telegram bot for Deno.

You can run it like so:

```shellscript
deno --allow-net example-bot.ts
```

### Advanced example

TODO: create more complicated example

```ts
const token = Deno.env.get('BOT_TOKEN')
```

```shellscript
deno --allow-net --allow-env example-bot.ts
```
Loading

0 comments on commit 9089b13

Please sign in to comment.