我们有一个电报机器人,它有大约120万用户.
现在在向这些订户数量发送消息时遇到了问题.
Telegram bot API不提供任何批量消息功能,我们必须将个别请求发送到电报.问题是在几千条消息之后,电报开始响应错误429:请求太多,并且暂时不接受任何请求.
我们如何有效地向订阅者发送消息?
这些运营商在Elixir中意味着什么? ~>>, <<~
它们列在这里http://elixir-lang.org/getting-started/basic-operators.html
我收到以下错误:
iex(28)> b=1
1
iex(29)> b~>>1
** (CompileError) iex:29: undefined function ~>>/2
Run Code Online (Sandbox Code Playgroud) 作为我之前的问题的后续跟进:
一些答案和评论表明了这一点
select count(*)主要是相当于select count(id)其中id是主键 .`
我一直很喜欢select count(1); 我甚至总是用if exists (select 1 from table_name)......
现在我的问题是:
1)发表select count query一张桌子的最佳方式是什么?
2)如果我们添加一个where子句:where msg_type = X; 如果msg_type有非聚集索引,将select count(msg_type) from table_name where msg_type = X是计数的首选选项?
边栏:
从很小的时候,我被教导说,select * from...是很坏很坏的坏,我想这已经让我怀疑SELECT COUNT(*),以及中
我做了一个电报机器人,它根据请求使用pyTelegramBotAPI包装器发送照片.所以我尝试放置一个虚拟照片URL并测试机器人是否可以发送图像,但它失败并出现以下错误.
telebot.apihelper.ApiException: sendPhoto failed. Returned result: <Response [400]>
我不确定错误是什么,但如何正确地使用Telegram Bot API从URL发送照片?这是我的代码
import telebot
import time
import urllib
from io import BytesIO
from PIL import Image
TOKEN = '<token here>'
url='http://scontent-b.cdninstagram.com/hphotos-xfa1/t51.2885-15/e15/10919672_584633251672188_179950734_n.jpg'
def listener(*messages):
for m in messages:
chatid = m.chat.id
if m.content_type == 'text':
text = m.text
name = m.fromUser.first_name
msgid = m.message_id
if(text.startswith('/photo')):
img = BytesIO(urllib.request.urlopen(url).read())
tb.send_chat_action(chatid, 'upload_photo')
tb.send_photo(chatid, img, reply_to_message_id=msgid)
tb = telebot.TeleBot(TOKEN)
tb.get_update() # cache exist message
tb.set_update_listener(listener) #register listener
tb.polling()
while True:
time.sleep(1)
Run Code Online (Sandbox Code Playgroud)
我不确定我是否错过了一些东西.
我几天前在youtube上看过这个教程.这非常有趣,所以我决定制作一个自己的机器人.我使用教程中的代码作为模板:
<?php
$bottoken = "*****";
$website = "https://api.telegram.org/bot".$bottoken;
$update = file_get_contents('php://input');
$updatearray = json_decode($update, TRUE);
$length = count($updatearray["result"]);
$chatid = $updatearray["result"][$length-1]["message"]["chat"]["id"];
$text = $updatearray["result"][$length-1]["message"]["text"];
if($text == 'hy'){
file_get_contents($website."/sendmessage?chat_id=".$chatid."&text=hello");
}
elseif($text == 'ciao'){
file_get_contents($website."/sendmessage?chat_id=".$chatid."&text=bye");
}
Run Code Online (Sandbox Code Playgroud)
如果我手动执行脚本,脚本会起作用.但是,当我使用webhook时,它不再起作用了.该教程说这$update = file_get_contents('php://input');是正确的方式,以前使用$update = file_get_contents($website."/getupdates");.我的问题如何php://input自动执行脚本?该脚本位于"one.com"的服务器上,证书也来自"one.com".
我有一个关于Telegram机器人的问题,几周前我创建了一个bot,它可以正常工作,但是getUpdates方法的行为异常;确实,如果我使用链接:
https://api.telegram.org/bot<token>/getUpdates
Run Code Online (Sandbox Code Playgroud)
现在我看不到任何消息,但是如果我启动一个新的漫游器,则此链接可以像创建另一个漫游器的第一天一样正常工作。
在特定时间间隔后,此链接会停止工作吗?有办法重新启用它吗?
提前致谢
我们如何使用GenServer实现可重置倒计时器?
1)在固定的时间之后执行任务,例如每60秒执行一次
2)有一种方法可以在计时器过去之前将倒计时重置为60秒
我已经了解了如何使用Erlang的gen_server定期执行操作?但它并没有完全涵盖在倒计时过去之前休息计时器的方面.
谢谢.
我正在尝试通过 SendVoice 方法发送语音消息,但它将语音作为简单的 ogg 文件发送(不可播放)。
https://api.telegram.org/bot<token>/sendVoice?chat_id=x&voice=http://majidamiri.com/up/5.ogg
Run Code Online (Sandbox Code Playgroud)
在Telegram API SendVoice中,它指出该文件应为 .ogg opus 格式,因此我使用以下代码通过 ffmpeg 将 mp3 文件转换为 opus ogg:
<?php $myConvert = exec('ffmpeg.exe -i 1.mp3 -acodec libopus -b:a 64k -vbr off -compression_level 10 5.ogg'); ?>
再次像之前一样将其作为文件发送。
我的 ogg 链接: https: //majidamiri.com/up/5.ogg
你能帮我解决这个问题吗?
谢谢你们 。
如果能将它放在标准 Elixir 库中就好了,但我们没有。
Date.add(date, n, :month) # where n could be +/-
Run Code Online (Sandbox Code Playgroud)
你会如何实施这个?
这看起来是一个很好的起点:https ://stackoverflow.com/a/53407676/44080
telegram-bot ×5
elixir ×4
count ×1
countdown ×1
date ×1
gen-server ×1
java ×1
operators ×1
php ×1
python ×1
select ×1
sql-server ×1
timer ×1
windows ×1