Skip to content

Commit

Permalink
Create example.nim
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidb80 authored Sep 28, 2023
1 parent 5081af1 commit 7997f39
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/example.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## says hello to anyone sends something

import std/[asyncdispatch, options, os]
import bale


let
token = getEnv "BALE_BOT_TOKEN"
bot = newBaleBot token

template forever(body): untyped =
while true:
body

proc main =
var skip = -1

forever:
try:
let updates = waitFor bot.getUpdates(offset = skip+1)
echo (updates.len, skip)

for u in updates:
skip = u.id
if u.msg.isSome:
let
msg = u.msg.get
chid = msg.chat.id

discard waitFor bot.sendMessage(chid, "heelo")

except:
echo "temp error"


when isMainModule:
main()

0 comments on commit 7997f39

Please sign in to comment.