我正在使用 getFile(),然后使用类似的链接下载照片https://api.telegram.org/file/bot<token>/<file_path>.
,但我只收到了他的缩略图
谁能问我如何下载真实尺寸的照片?
我正在尝试使用 Telegram 机器人用户将 pdf 文档和有关它的小描述从我的服务器发送到 Telegram 组。我可以使用 /sendDocument 方法自行发送文档。然而,这并不完全是我想要的。我想知道这可能吗?
curl -F chat_id="-xxxxxxxxxx" -F document=@"/home/telegram/someFile.pdf" -F text="Text Message with attachment" https://api.telegram.org/bot<token>/sendMessage
Run Code Online (Sandbox Code Playgroud) 我正在开发一个电报机器人,我需要将外部网站的链接发送到频道中。我注意到,当我在聊天中手动粘贴链接时,用户只需单击该链接即可导航到该网站,另一方面,单击从机器人发送的链接,会显示确认导航的警报
我正在使用带有自定义库的 Java 来与 Telegram Bot API 进行交互。我正在使用 SendMessage 操作向频道发送消息。
解析模式是 HTML,我正在发送带有链接的 html 锚标记的小文本。
我有一个处理程序express.js,它将文件的ID 作为输入。
我不知道如何通过 axios 等捕获该文件的流并将其传输到客户端部分 SPA。
感谢您的关注
router.get('/api/track/:id', async(req, res) => {
// Create bot
const telegram = new Telegram(token, { agent })
const fileId = req.params.id
let url
try {
// Getting filelink from telegram
url = await telegram.getFileLink(fileId)
} catch (error) {
console.log('Error on getting link on file from telegram', error)
return { message: 'Error on getting link on file from telegram', code: 4, error}
}
res.set('content-type', 'audio/mp3');
res.set('accept-ranges', 'bytes');
// And this is place i'm try download …
Run Code Online (Sandbox Code Playgroud)下面是我用于电报机器人的代码,该机器人从我喜欢的 Reddit 子版块发布新的更新。这不是我的代码(我在堆栈溢出上在线找到它),但我不断收到此错误。我到处搜索但没有找到任何解决方案。无论如何,即使是关于我应该走哪个方向的轻微信息也将不胜感激。
import telebot
import praw
import config
bot_token = 'x'
bot_chatID = '@monsterKing_bot'
bot = telebot.TeleBot(bot_token)
reddit = praw.Reddit(client_id='x', \
client_secret='x', \
user_agent='x', \
username='x ', \
password='x')
def reddit_scraper(submission):
news_data = []
subreddit = reddit.subreddit('coronavirus')
new_subreddit = subreddit.new(limit=500)
for submission in subreddit.new(limit=5):
data = {}
data['title'] = submission.title
data['link'] = submission.url
news_data.append(data)
return news_data
def get_msg(news_data):
msg = '\n\n\n'
for news_item in news_data:
title = news_item['title']
link = news_item['link']
msg += title+'\n[<a href="'+link+'">Read the full article --></a>]' …
Run Code Online (Sandbox Code Playgroud) 我找到了聊天记录并在那里找到了贴纸。我想从我的历史记录中获取所有贴纸并在我的机器人中使用它。但有一个问题:Telegram Api 标识符的格式与 Telegram Bot Api 格式不同,例如:
telegram api 贴纸 ID - 280235483508769025;
电报机器人 API 贴纸 ID - CAADAgADOQADfyesDlKEqOOd72VKAg。
(顺便说一下,这是不同的贴纸)
那么,有没有办法将贴纸的 Telegram Api 格式的 id 转换为 Telegram Bot Api 格式的 id?280235483508769025 -> CAADAgADOQADfyesDlKEqOOd72VKAg?
PS Telegram Api ID 格式 - https://core.telegram.org/type/InputDocument
Telegram Bot Api ID 格式 - https://core.telegram.org/bots/api#sendphoto
我有一个机器人,它运行得很好。但是我如何引用触发机器人的消息以便用户知道机器人回复了他?
这是我用来返回消息的代码。
return res.status(200).send({
method: 'sendMessage',
chat_id,
text: `Hello, welcome to <bot_name>`,
parse_mode: 'Markdown'
})
Run Code Online (Sandbox Code Playgroud)
我想在回复中引用该消息,如下所示:
给出下面的代码:
def start(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text="I'm a bot, please talk to me!")
Run Code Online (Sandbox Code Playgroud)
是否可以定期调用此函数并使我的机器人自动将消息发送给用户,而不是用户键入“/start”
是否可以删除我与机器人聊天的所有聊天记录(消息)。
所以控制台版本是这样的:
import os
os.sys("clear") - if Linux
os.sys("cls") - if Windows
Run Code Online (Sandbox Code Playgroud)
我想要的只是使用 bot 删除聊天中的所有消息。
def deleteChat(message):
#delete chat code
Run Code Online (Sandbox Code Playgroud) 我想从接收更新中读取用户名,但我遇到了一个特殊问题.
对于某些用户,$message['from']['username']
包含Telegram用户名,但是对于某些用户,此参数未定义.
如何username
使用Telegram Bot API 可靠地接收用户名(获取字段)?
我在尝试删除时收到以下错误Message
:
2018-04-10 13:58:57,646 (__init__.py:292 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: message can\'t be deleted"}']"
Run Code Online (Sandbox Code Playgroud)
为什么留言无法删除?
import config
import telebot
bot = telebot.TeleBot(config.token)
@bot.message_handler(content_types=["text"])
def repeat_all_messages(message):
bot.send_message(message.chat.id, 'Hello World')
bot.delete_message(message.chat.id, message.message_id)
if __name__ == '__main__':
bot.polling(none_stop=True)
Run Code Online (Sandbox Code Playgroud) 到目前为止,我的机器人正在工作,但问题是它只能发送文本。我已经在Bot API中看到了发送照片,视频的功能...但是我无法正常工作。有人实现了吗?我正在使用yukuku / telebot的 python源代码
elif text == '/image':
img = Image.new('RGB', (512, 512))
base = random.randint(0, 16777216)
pixels = [base+i*j for i in range(512) for j in range(512)] # generate sample image
img.putdata(pixels)
output = StringIO.StringIO()
img.save(output, 'JPEG')
reply(img=output.getvalue())
Run Code Online (Sandbox Code Playgroud)
当我更改代码时,什么也没发生。
img = Image.open('image.png')
img.show()
Run Code Online (Sandbox Code Playgroud)
请帮我。我需要正确的代码。对不起,我的英语不好。
telegram-bot ×13
telegram ×9
python ×4
node.js ×2
python-3.x ×2
api ×1
axios ×1
express ×1
firebase ×1
java ×1
praw ×1
reddit ×1
typescript ×1