Simple messaging server as an experimentation with asynchronous programming in C.
Build with make and run ribezal preferably in background.
$ make
$ ./ribezal &You can send "messages" to the server by writing to input-fifo, e.g.:
$ echo "your command" > input-fifoStop the server with command quit:
$ echo "quit" > input-fifoYou can communicate with ribezal using a little stack based language. (At the moment this is just a simple calculator). Commands are separated by whitespace. Integers are recognised as such and pushed to the stack. All commands that are not integers or keywords are pushed as strings to the strings.
When calling ribezal you can specify a file containing stack code as a command line argument. This code is executed before everything else. That way you can e.g. specify your private telegram bot token conveniently.
There are the following keywords:
help:- Stack: (->)
- Description: Prints documentation for the commands.
quit:- Stack: (->)
- Description: Closes this repl.
print:- Stack: (->)
- Description: Prints out the current stack.
drop:- Stack: tbd
- Description: Removes the top element from stack.
clear:- Stack: tbd
- Description: Removes all elements from stack.
+:- Stack: (int int -> int)
- Description: Adds two numbers.
-:- Stack: (int int -> int)
- Description: Subtracts one number from the other.
*:- Stack: (int int -> int)
- Description: Multiplies two numbers.
/:- Stack: (int int -> int)
- Description: Divides one number by the other.
tg-getMe:- Stack: (->)
- Description: Performs a 'getMe' call to the telegram api and gives some informative output.
tg-getUpdates:- Stack: (->)
- Description: Performs a 'getUpdates' call to the telegram api and gives some informative output.
set-bot-token:- Stack: (string ->)
- Description: Sets a global telegram bot token which is used by all calls to the telegram bot api.
get-bot-token:- Stack: (-> string)
- Description: Pushes the global telegram bot token to the stack.
set-last-update-id:- Stack: (int ->)
- Description: Sets the update id by which the telegram updates are filtered.
get-last-update-id:- Stack: (-> int)
- Description: Pushes the update id of the last processed telegram update to the stack.
tg-sendMessage:- Stack: (int string ->)
- Description: Sends a telegram message using the global bot token to the specified chat id.
- telegram bot api
- arena.h
- utest.h
- json.h
- c3fut (inspirational): a futures implementation for the language C3 using interfaces
- Pool Allocator (inspirational): excellent explanation of the principle of a pool allocator