-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Framework extension with callbacks and integrated update handler to help developers get started quicker. - Bugfixes
- Loading branch information
Showing
4 changed files
with
348 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- pass token as command line argument or insert it into code | ||
local token = arg[1] or "" | ||
|
||
-- create and configure new bot with set token | ||
local bot, extension = require("lua-bot-api").configure(token) | ||
|
||
-- override onMessageReceive function so it does what we want | ||
extension.onMessageReceive = function (msg) | ||
print("New Message by " .. msg.from.first_name) | ||
|
||
if (msg.text == "/start") then | ||
bot.sendMessage(msg.from.id, "Hello there 👋\nMy name is " .. bot.first_name) | ||
elseif (msg.text == "ping") then | ||
bot.sendMessage(msg.chat.id, "pong!") | ||
else | ||
bot.sendMessage(msg.chat.id, "I am just an example, running on the Lua Telegram Framework written with ❤️ by @cosmonawt") | ||
end | ||
end | ||
|
||
-- override onPhotoReceive as well | ||
extension.onPhotoReceive = function (msg) | ||
print("Photo received!") | ||
bot.sendMessage(msg.chat.id, "Nice photo! It dimensions are " .. msg.photo[1].width .. "x" .. msg.photo[1].height) | ||
end | ||
|
||
-- This runs the internal update and callback handler | ||
-- you can even override run() | ||
extension.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.