Giter Club home page Giter Club logo

pytmi's People

Contributors

bynect avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pytmi's Issues

[Q] What is `part` method?

I'm facing an issue that only occurs after the first connection with pytmi. I see:

Unknown exception 0 bytes read on a total of undefined expected bytes

in my console on subsequent requests. My run loop generally looks like this:

@router.websocket("/chat")
async def scan_chat(websocket: WebSocket, channel: str = ''):
    await websocket.accept()

    twitch_client = pytmi.Client(use_ssl=False)

    try:
        await twitch_client.login_anonymous()
        await twitch_client.join(channel)
    except Exception as e:
        print("Login failed: {}".format(e))
        pass

    async def get_message_loop():
        msg = await twitch_client.get_message()
        if msg is None or not msg.valid or not "PRIVMSG" in msg.command:
            return

        privmsg = msg.command.split(" :", 1)[1]
        sender = msg.tags.get('display-name', '')
        await websocket.send_text(privmsg)

        del msg

    try:
        while True:
            await get_message_loop()
    except ConnectionClosedOK:
        pass
    except ConnectionClosedError as e:
        print("Twitch: ConnectionClosedError {}".format(e))
        pass
    except Exception as e:
        print("Unknown exception {}".format(e))
        pass
    finally:
        await twitch_client.logout()
        await websocket.close()
        print('Disconnected a Twitch client for {}'.format(channel))

I'm looking for a method to close my connections properly. I saw part in the example code near the end. Will that be helpful for resolving this?

I'm not sure if these are relevant but I see these as well:

Login failed: Unable to complete login
Tried 8 times, got 8 errors:
readuntil() called while another coroutine is already waiting for incoming data

unable to perform operation on <TCPTransport closed=True reading=False 0x7fd51f75cf90>; the handler is closed
unable to perform operation on <TCPTransport closed=True reading=False 0x7fd51f75cf90>; the handler is closed
unable to perform operation on <TCPTransport closed=True reading=False 0x7fd51f75cf90>; the handler is closed
unable to perform operation on <TCPTransport closed=True reading=False 0x7fd51f75cf90>; the handler is closed
unable to perform operation on <TCPTransport closed=True reading=False 0x7fd51f75cf90>; the handler is closed
unable to perform operation on <TCPTransport closed=True reading=False 0x7fd51f75cf90>; the handler is closed

Unknown exception Not logged in

...
Login failed: [Errno 54] Connection reset by peer

How can I use Pytmi Async?

I can use the twitch api directly, but not in Pyqt5. What should I do? I couldn't find the answer for hours. What should I do, where should I write? I can't run it in the interface. It works without interface. It does nothing with the interface. How can I run it? Thank you.

This is how it's work:

`import asyncio
import pytmi

listToken = ["Token List"]
listNick = ["User List"]
channel = "**************************"
messagesList = ["Hello","Hi","Goodnight"]
for i in range(0,3):

async def main() -> None:
    # nick = input("Insert your Twitch nickname: ").lstrip()
    # token = input("Insert your Twitch OAuth token: ").lstrip()
    # channel = input("Insert the channel to join: ").lstrip()

    client = pytmi.TmiClient()
    await client.login_oauth(listToken[i], listNick[i])

    await client.join(channel)
    await client.send_privmsg(messagesList[i])

    await client.part(channel)
    await client.logout()


if __name__ == "__main__":
    try:
        loop = asyncio.new_event_loop()
        loop.run_until_complete(main())
    except:
        print("Something went wrong.")`

Not running:

`def YorumAttirCalistir(self):

    os.chdir("Data")
    os.chdir("Kullanıcılar")
    listToken = []
    listNick = []
   
    dosyaOuath = open("Oauth.txt", "r", encoding="UTF8")
    for i in dosyaOuath:
        i = i[:-1]
        listToken.append(i)
        newListToken = listToken
    dosyaNick = open("Oauth.txt", "r", encoding="UTF8")
    for i in dosyaNick:
        i = i[:-1]
        listNick.append(i)
        newListNick = listNick
    os.chdir("..")
    os.chdir("..")
    os.chdir("Data")
    os.chdir("Chat")
    os.chdir("Valorant Chat")
    messagesList = []
    dosyaComment = open("Valorant.txt", "r", encoding="UTF8")
    for i in dosyaComment:
        i = i[:-1]
        messagesList.append(i)
        newListMessages = messagesList   
    channel = "shawncutstheh"
    token = newListToken
    nick = newListNick
    yorum = newListMessages
    def YorumAttir():
        for i in range(0,4):
            async def main() -> None:
                    # nick = input("Insert your Twitch nickname: ").lstrip()
                    # token = input("Insert your Twitch OAuth token: ").lstrip()
                    # channel = input("Insert the channel to join: ").lstrip()

                client = pytmi.TmiClients()
                await client.login_oauth(token[i], nick[i])

                await client.join(channel)
                await client.send_privmsg(yorum[i])

                await client.part(channel)
                await client.logout()


                if __name__ == "__main__":
                    try:
                        loop = QEventLoop.new_event_loop()
                        loop.run_until_complete(main())
                    except:
                        print("Something went wrong.")
    YorumAttirThread = threading.Thread(
        target=YorumAttir)
   YorumAttirThread.start()`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.