Skip to content

Commit fc074c5

Browse files
committed
mark callback procs as {.gcsafe.} to avoid exception when threads is enabled, fixes #45
1 parent 2da3f0d commit fc074c5

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

examples/echo_bot.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ../telebot, asyncdispatch, logging, options, sam
1+
import ../telebot, asyncdispatch, logging, options
22
from strutils import strip
33

44
var L = newConsoleLogger(fmtStr="$levelname, [$time] ")

telebot/helpers.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import types, options
1+
import types
22

33
# -------------
44
# InputMessageContent

telebot/inputmedia.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import types, strutils, utils, options, macros
1+
import types, strutils, utils, options
22

33
proc `$`*(m: InputMedia): string =
44
result = ""

telebot/types.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import asyncdispatch, options, tables, httpclient
33
type
44
TelegramObject* = object of RootObj
55

6-
UpdateCallback* = proc(bot: Telebot, update: Update): Future[void]
7-
CommandCallback* = proc(bot: Telebot, command: Command): Future[void]
8-
CatchallCommandCallback* = proc(bot: Telebot, command: CatchallCommand): Future[void]
9-
InlineQueryCallback* = proc(bot: Telebot, inlineQuery: InlineQuery): Future[void]
6+
UpdateCallback* = proc(bot: Telebot, update: Update): Future[void] {.gcsafe.}
7+
CommandCallback* = proc(bot: Telebot, command: Command): Future[void] {.gcsafe.}
8+
CatchallCommandCallback* = proc(bot: Telebot, command: CatchallCommand): Future[void] {.gcsafe.}
9+
InlineQueryCallback* = proc(bot: Telebot, inlineQuery: InlineQuery): Future[void] {.gcsafe.}
1010

1111
TeleBot* = ref object of TelegramObject
1212
token*: string

telebot/utils.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ proc formatName*(s: string): string =
7373
proc unmarshal*(n: JsonNode, T: typedesc): T =
7474
when result is object:
7575
for name, value in result.fieldPairs:
76-
const jsonKey = formatName(name)
76+
let jsonKey = formatName(name)
7777
when value.type is Option:
7878
if n.hasKey(jsonKey):
7979
toOption(value, n[jsonKey])

telebot/webhook.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ proc startWebhook*(b: Telebot, secret, url: string, port=Port(8080)) =
6363

6464
waitFor b.setWebhook(url)
6565

66-
proc callback(req: Request) {.async, gcsafe.} =
66+
proc callback(req: Request) {.async.} =
6767
d("GET: ", req.body)
6868
if req.url.path == "/" & secret:
6969
try:

0 commit comments

Comments
 (0)