pyTelegramBotAPI 版本 - 3.0.1
python版本:2.7/3.6.1
我想创建一个带参数的命令,例如:
/activate 1
/run programm
Run Code Online (Sandbox Code Playgroud)
怎么做?
我使用创建一个电报机器人telegraf使用向导。我想在我的机器人中有几个向导。如何进入另一个场景?我正在使用以下代码,但出现错误Cannot read property 'enter' of undefined。
const Stage = require("telegraf/stage");
const WizardScene = require("telegraf/scenes/wizard");
const wiz1 = new WizardScene('task1',
ctx => {...},
ctx => {...}
);
const wiz2 = new WizardScene('task2',
ctx => {...},
ctx => {...}
);
const wiz3 = new WizardScene('task3',
ctx => {...},
ctx => {...}
);
const stage =new Stage([wiz1,wiz2,wiz3],{default: 'task1'})
bot.hears('anAction', (ctx) => {Stage.enter('wiz2')}); // this does not work
Run Code Online (Sandbox Code Playgroud) 在 CentOS 8 中配置 Kubernetes 1.17 时,kubeadm 发出警告说tc命令不在路径中。
CentOS 8 中删除了 tc 命令,对于 Kubernetes 主机上没有此命令有何影响?
tc - show / manipulate traffic control settings
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在编写一个 Telegram 机器人。我想在电报频道中搜索特定消息并获取其消息 ID。是否可以?提前谢谢。
我想在我的 kubernetes 集群上部署入门镜像。
我在一个簇中有三个覆盆子
> kubectl version -o json ~
{
"clientVersion": {
"major": "1",
"minor": "18",
"gitVersion": "v1.18.2",
"gitCommit": "52c56ce7a8272c798dbc29846288d7cd9fbae032",
"gitTreeState": "clean",
"buildDate": "2020-04-16T11:56:40Z",
"goVersion": "go1.13.9",
"compiler": "gc",
"platform": "linux/arm"
},
"serverVersion": {
"major": "1",
"minor": "18",
"gitVersion": "v1.18.2",
"gitCommit": "52c56ce7a8272c798dbc29846288d7cd9fbae032",
"gitTreeState": "clean",
"buildDate": "2020-04-16T11:48:36Z",
"goVersion": "go1.13.9",
"compiler": "gc",
"platform": "linux/arm"
}
}
> docker -v ~
Docker version 19.03.8, build afacb8b
> kubectl get node ~
NAME STATUS ROLES AGE VERSION
master-pi4 Ready master 18h v1.18.2
node1-pi4 Ready …Run Code Online (Sandbox Code Playgroud) 我有一个通过主机名知道的特定节点(如 中所示kubectl describe pods)。我怀疑硬件不兼容,并希望将该节点从我的工作中排除。
我尝试使用podAntiAffinity但没有成功(我的工作仍然分配给my.hostname.net)。完成此任务的正确方法是什么?
apiVersion: batch/v1
kind: Job
metadata:
name: my-job-name
spec:
backoffLimit: 0
template:
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: kubernetes.io/hostname
operator: NotIn
values:
- my.hostname.net
topologyKey: kubernetes.io/hostname
containers:
<<the rest omitted>>
Run Code Online (Sandbox Code Playgroud) 我已经在 ubuntu 上通过 pip 和 pip3 安装了 python-telegram-bot 包,并尝试加载它:
from telegram.ext import Updater, CommandHandler
Run Code Online (Sandbox Code Playgroud)
然后我得到:
File "/usr/local/lib/python3.5/dist-packages/telegram/base.py", line 42
_id_attrs: Tuple[Any, ...] = ()
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
我在 python 2.7 版本中遇到了类似的错误。“base.py”文件有一行带有“ _id_attrs:”,我已经使用 python 一段时间了,但从未见过变量名后跟冒号。使这一行对 python 可读是什么意思。
我有一个工作区,可以在其中添加不同的对象。有一种场景,双击时可以在工作区中自动添加一个对象。我尝试过不同的解决方案,但没有一个真正有效。
这是我尝试过的:
await page.evaluate(selector => {
var targLink = document.querySelector(selector);
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent('dblclick', true, true);
targLink.dispatchEvent(clickEvent);
}, selector)
Run Code Online (Sandbox Code Playgroud) 尝试运行Telethon 文档提供的基本代码时,我收到以下错误。我很困惑,因为我还没有建立一个循环。
RuntimeError:如果事件循环正在运行,则必须使用“async with”(即您在“async def”中)
我在 spyder 4.0.1 中使用 python 3.7.7
from telethon.sync import TelegramClient
from telethon import functions, types
def channel_info(username, api_id, api_hash):
with TelegramClient(username, api_id, api_hash,channel) as client:
result = client(functions.channels.GetFullChannelRequest(
channel=channel
))
return(result)
out = channel_info(username, api_id, api_hash)
Run Code Online (Sandbox Code Playgroud) 如果我理解正确的话,用关键字async声明的函数应该返回一个承诺。对于async3函数,我们有 10 亿次迭代,这使得返回值需要更长的时间。分析下面的代码,我期望发生的是,通过调用sync1和sync2函数,立即登录控制台,稍后,async3函数日志就会出现。但是,我注意到,sync1和sync2函数仅在async3结束后才记录。难道async3函数不应该在另一个线程上或在事件循环之外运行,而不阻止运行时调用的其他函数的执行吗?
function sync1() {
console.log(1);
}
function sync2() {
console.log(2);
}
async function async3() {
let iteration = 0;
let number = 0;
while (iteration <= 1000000000) {
number = iteration;
iteration++;
}
return number;
}
sync1();
sync2();
async3().then((val) => console.log(val));Run Code Online (Sandbox Code Playgroud)
你能解释一下为什么它会这样吗?我缺少什么?
我所期望的:
sync1(); // console logged immediately
sync2(); // console logged immediately
async3().then((val) => console.log(val)); // console logged moments later
Run Code Online (Sandbox Code Playgroud)
目前发生的事情:
同步1(); … 我试图理解为什么这段代码不像我期望的那样表现:
async function test() {
await setTimeout(() => {
console.log('done')
}, 1000)
console.log('it finished');
}
test();Run Code Online (Sandbox Code Playgroud)
这首先打印it finished,然后打印done。这段代码不应该在执行之前等待超时完成console.log('it finished');还是我误解了什么?
python ×5
telegram ×5
javascript ×3
kubernetes ×3
async-await ×2
bots ×2
api ×1
arguments ×1
centos8 ×1
es6-promise ×1
node.js ×1
playwright ×1
puppeteer ×1
telegraf ×1
telegram-bot ×1
telethon ×1