标签: telegram-bot

电报BOT Api:如何使用PHP发送照片?

所述sendPhoto命令需要一个参数photo定义为InputFile or String.

API文档告诉:

Photo to send. You can either pass a file_id as String to resend a photo
that is already on the Telegram servers, or upload a new photo using
multipart/form-data.
Run Code Online (Sandbox Code Playgroud)

InputFile

This object represents the contents of a file to be uploaded. Must be
posted using multipart/form-data in the usual way that files are 
uploaded via the browser. 
Run Code Online (Sandbox Code Playgroud)

所以我尝试了这种方法

    $bot_url    = "https://api.telegram.org/bot<bot_id>/";
    $url = $bot_url . "sendPhoto?chat_id=" . $chat_id;
    $ch …
Run Code Online (Sandbox Code Playgroud)

php curl telegram telegram-bot

7
推荐指数
1
解决办法
4万
查看次数

如何将Telegram BOT命令隐藏为组的一部分?

我正在尝试使用Telegram BOT向群组发送消息.首先,我认为知道群聊聊天ID就足以实现这一点,但事实并非如此.BOT必须是该组的一部分.好吧,这有点意义,但问题是:当你将一个BOT添加到一个组(在这种情况下是一个大组)时,每个人都开始在他们的设备上看到一个新图标,一个"斜线"图标.他们做了什么?他们点击它,看到命令列表,选择其中一个,突然之间每个人都从组中收到一条新消息:"/ something".想象一下,有几十个人这样做?这很烦人.所以,这些都适合我:

1)我可以在没有BOT的情况下从BOT向群组发送消息吗?2)我可以有一种"无方法"BOT,只发送消息吗?3)我可以禁用客户端的"斜线"图标,这样我就不会在组中进行"机器人方法战"吗?

谢谢

telegram telegram-bot

7
推荐指数
1
解决办法
5577
查看次数

如何限制访问电报机器人

当我向Telegram Bot发送消息时,它没有任何问题.

我想限制访问,以便我和只有我可以向它发送消息.

我怎样才能做到这一点?

python-telegram-bot telegram-bot

7
推荐指数
4
解决办法
7979
查看次数

如何在电报机器人上发送照片

我只是实现了一个简单的机器人,该机器人应该将一些照片和视频发送给我chat_id。好吧,我正在使用python,这是脚本

import sys
import time
import random
import datetime
import telepot

def handle(msg):
    chat_id = msg['chat']['id']
    command = msg['text']

    print 'Got command: %s' % command

    if command == 'command1':
        bot.sendMessage(chat_id, *******)
    elif command == 'command2':
        bot.sendMessage(chat_id, ******)
    elif command == 'photo':
        bot.sendPhoto(...)

bot = telepot.Bot('*** INSERT TOKEN ***')
bot.message_loop(handle)
print 'I am listening ...'

while 1:
    time.sleep(10)
Run Code Online (Sandbox Code Playgroud)

在这一行中,bot.sendphoto我将插入chat_id图像的路径和,但是什么也没有发生。

我哪里错了?

谢谢

python telegram-bot telepot

7
推荐指数
6
解决办法
1万
查看次数

firebase.intializeApp不是一个函数

所以我坚持这个错误.我正在用电报bot api制作一个电报机器人,现在我试图设置一个firebae数据库来保存一个组成员的分数 - 所以在重新启动机器人后不会重置分数.谁能告诉我问题是什么?我在这里阅读了许多类似的问题,但这些答案都没有解决我的问题.

bot.js

var TelegramBot = require('node-telegram-bot-api');
var firebase = require('firebase');

var token = 'mytoken';
// Setup polling way
var bot = new TelegramBot(token, {polling: true});

var app = firebase.intializeApp({
  serviceAccount: "C:/Mayer/scorebot/telegramscorebot.json",
  databaseURL: "https://blazing-heat-2008.firebaseio.com/"
});


/* function Person(name, score) {
this.name = name;
this.score = score;
}

var member = new Array();
member[0] = new Person("name1", 0);
member[1] = new Person("name2", 0);
member[2] = new Person("name3", 0);
member[3] = new Person("name4", 0);
member[4] = new Person("name5", 0); */ …
Run Code Online (Sandbox Code Playgroud)

node.js firebase telegram-bot

7
推荐指数
2
解决办法
5476
查看次数

用php机器人发送带有照片的长信息

我需要用照片发送电报长文本但电报图像标题有200个字符限制.如何使用php和bot发送带有照片的长文本?sendPhoto方法有200个字符限制.我看到一个电报机器人它发送长文本和照片看到我的样本照片.

这是发送到telegrem的示例图像

php telegram telegram-bot

7
推荐指数
2
解决办法
1万
查看次数

使用sendPhoto发送动画GIF(Telegram bot)

我正在尝试使用sendPhoto(Telegram的Bot API)发送带有此请求的动画GIF:

https://api.telegram.org/bot<token>/sendPhoto?chat_id=<chat_id>&photo=http://i.giphy.com/13IC4LVeP5NGNi.gif
Run Code Online (Sandbox Code Playgroud)

该方法有效,我ok:true回来了,但聊天窗口中的图像是移动GIF​​的静态快照.

如何才能显示动画GIF?我应该使用另一种方法吗?

telegram telegram-bot php-telegram-bot

7
推荐指数
2
解决办法
9407
查看次数

Telegram Bot"找不到聊天"

我在Python中使用以下代码从机器人向自己发送消息.

import requests

token = '320835125:AAFUUC-fdo_EFzsCjvmxu8HBk7qVzZXXXXX'
method = 'sendMessage'
myuserid = 1949275XX
response = requests.post(
    url='https://api.telegram.org/bot{0}/{1}'.format(token, method),
    data={'chat_id': myuserid, 'text': 'hello friend'}
).json()
print(response)
Run Code Online (Sandbox Code Playgroud)

但这会回来 {'description': 'Bad Request: chat not found', 'error_code': 400, 'ok': False}

我究竟做错了什么?我myuserid通过发送/getid@myidbot获得我的令牌@BotFather

python python-requests telegram telegram-bot

7
推荐指数
3
解决办法
1万
查看次数

Telegram 机器人应发送包含“&amp;”字符的 URL,但它仅发送该字符之前的 URL,然后将其缩短

我希望我的 Telegram 机器人将 URL 发送到频道。但是,该 url 包含“&”字符,该字符会缩短尝试发送的消息。Telegram API 文档说我需要使用 & (没有空格)来替换 & 但要么我不明白某些东西,要么它不起作用。

这就是我正在做的:

requests.get("https://api.telegram.org/"+botID+"/sendMessage?chat_id="+chatid+"&text="+movieSearch+"&parse_mode=HTML")
Run Code Online (Sandbox Code Playgroud)

movieSearch 是:

movieSearch = ("https://www.imdb.com/search/title?release_date="+year+"-01-01,2018-12-31&user_rating="+score+",&genres="+genres)
Run Code Online (Sandbox Code Playgroud)

您可以看到,在 movieSearch 中,release_date 之后有 &user_ rating=... 等等。但是,机器人只会在 & 字符之前发送 URL(因此直到“2018-12-31”)。

我尝试将 & 替换为 & amp; 但它仍然不会发送整个 URL。我尝试过不使用 parse_mode=HTML 但它也不起作用。

python bots telegram python-telegram-bot telegram-bot

7
推荐指数
1
解决办法
1万
查看次数

如何在 Python-telegram-bot 中使用 Jobqueue

我可以通过阅读文档非常轻松地创建一个机器人,但是 Jobqueue 并没有按照它所写的那样工作。该run_daily方法使用datetime.time对象在特定时间发送消息,但此代码既不执行发送消息的工作,也不显示任何错误。它只是继续运行

    import datetime
    from telegram import bot
    from telegram.ext import Updater
    def callback_minute(bot, job):
        bot.send_message(chat_id=475838704, text='PlEaSe wOrK!')

    def main():
        updater = Updater()
        bot = updater.bot
        job = updater.job_queue

        dispatcher = updater.dispatcher

        job.run_daily(callback_minute, time=datetime.time(6,33,00))

        updater.start_polling()
        updater.idle()

    if __name__ == '__main__':
        main()
Run Code Online (Sandbox Code Playgroud)

python job-queue python-3.x python-telegram-bot telegram-bot

7
推荐指数
1
解决办法
2万
查看次数