27 lines
567 B
Julia
27 lines
567 B
Julia
|
module Bot
|
||
|
|
||
|
export find_username
|
||
|
|
||
|
using Logging
|
||
|
using Telegram, Telegram.API
|
||
|
import ..fetch_in_env
|
||
|
|
||
|
TG_TOKEN = fetch_in_env("TG_TOKEN_MARKOV")
|
||
|
CHAT_ID = parse(Int, fetch_in_env("TG_CHAT_ID"))
|
||
|
|
||
|
TELEGRAM_BOT = TelegramClient(TG_TOKEN, use_globally=false)
|
||
|
|
||
|
function find_username(user_id)
|
||
|
global TELEGRAM_BOT, CHAT_ID
|
||
|
@debug "Fetching user" user_id
|
||
|
u = getChatMember(TELEGRAM_BOT, user_id=user_id, chat_id=CHAT_ID)
|
||
|
u[:user][:username]
|
||
|
end
|
||
|
|
||
|
function register_command(commands...)
|
||
|
global TELEGRAM_BOT
|
||
|
setMyCommands(TELEGRAM_BOT, commands)
|
||
|
end
|
||
|
|
||
|
end
|