所以,我今天尝试在Python3.7中制作一个TwitchChat(IRC)记录器。在运行python -m pip install pipenv
pipenv --python 3.7
pipenv install setproctitle
pipenv install twitchio
pipenv run pip install --upgrade git+https://github.com/Gallopsled/pwntools.git@dev3
之后,当我运行记录器.py地址:
2019-12-20
Task exception was never retrieved
future: <Task finished coro=<WebsocketConnection.auth_seq() done, defined at /home/zoe/.local/share/virtualenvs/Twitch-Dev-B4hlqNxh/lib/python3.7/site-packages/twitchio/websocket.py:200> exception=KeyError('zoes17')>
Traceback (most recent call last):
File "/home/zoe/.local/share/virtualenvs/Twitch-Dev-B4hlqNxh/lib/python3.7/site-packages/twitchio/websocket.py", line 280, in _join_channel
await asyncio.wait_for(fut, timeout=10)
File "/usr/lib/python3.7/asyncio/tasks.py", line 449, in wait_for
raise futures.TimeoutError()
concurrent.futures._base.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/zoe/.local/share/virtualenvs/Twitch-Dev-B4hlqNxh/lib/python3.7/site-packages/twitchio/websocket.py", line 228, in auth_seq
await self.join_channels(*channels)
File "/home/zoe/.local/share/virtualenvs/Twitch-Dev-B4hlqNxh/lib/python3.7/site-packages/twitchio/websocket.py", line 271, in join_channels
await asyncio.gather(*[self._join_channel(x) for x in channels])
File "/home/zoe/.local/share/virtualenvs/Twitch-Dev-B4hlqNxh/lib/python3.7/site-packages/twitchio/websocket.py", line 282, in _join_channel
self._pending_joins.pop(channel)
KeyError: 'zoes17'
^C/home/zoe/.local/share/virtualenvs/Twitch-Dev-B4hlqNxh/lib/python3.7/site-packages/twitchio/websocket.py:618: RuntimeWarning: coroutine 'WebSocketCommonProtocol.close' was never awaited
self._websocket.close()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
这是我们的相关代码记录器.py它似乎连接,但在10秒超时后崩溃。我正在使用oauth:oathkeyFromTwitch作为使用.env文件在TMI_TOKEN
env varrible中输入我的密码。你知道吗
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Logger main class."""
import os # for importing env vars for the bot to use
import sys # for argument processing
from datetime import *
from pwnlib.term import text
from setproctitle import setproctitle
from twitchio.ext import commands
channel = ""
if len(sys.argv) > 1:
channel = sys.argv[1]
bot = commands.Bot(
# set up the bot
irc_token=os.environ['TMI_TOKEN'],
client_id=os.environ['CLIENT_ID'],
nick=os.environ['BOT_NICK'],
prefix=os.environ['BOT_PREFIX'],
initial_channels=[os.environ['CHANNEL'], channel]
)
@bot.event
async def event_ready():
'Called once when the bot goes online.'
print(f"{os.environ['BOT_NICK']} is online!")
ws = bot._ws # this is only needed to send messages within event_ready
await ws.send_privmsg(os.environ['CHANNEL'], f"/me has landed!")
@bot.event
async def event_message(ctx):
"""Runs every time a message is sent in chat."""
# make sure the bot ignores itself and the streamer
if ctx.author.name.lower() == os.environ['BOT_NICK'].lower():
return
await bot.handle_commands(ctx)
if 'hello' in ctx.content.lower():
await ctx.channel.send(f"Hi, @{ctx.author.name}!")
if __name__ == "__main__":
from commands import Handler as command_handler
bot.run()
我那乱七八糟的大脑缺了什么?你知道吗
initial_channels=[os.environ['CHANNEL'], channel]
需要成为:initial_channels=[os.environ['CHANNEL']]
或initial_channels=[channel]
中的相关代码命令.Bot因此实例化:
相关问题 更多 >
编程相关推荐