Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7433583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:41:40+00:00 2026-05-29T09:41:40+00:00

I am slowly learning Python and thumbing through the tutorials. I feel I have

  • 0

I am slowly learning Python and thumbing through the tutorials. I feel I have a basic understanding of how it works.

As a creative project I want to make an IRC bot. I don’t want to use a pre-established framework. I do not intend to reinvent the wheel, I simply want to construct a bot from the ground-up as both a learning project and a creative outlet. One issue I am encountering consistently in my minute knowledge of how to do this is that my bot seems to be responding to my commands ad infinitum. Here’s the code:

HOST="irc.durd.net"
PORT=6667
NICK="Data"
IDENT="data"
REALNAME="databot"
HOME='#zela'
feedback=""

s=socket.socket( )
s.connect((HOST, PORT))
s.send("NICK %s\r\n" % NICK)
s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
s.send("JOIN #zela" + "\r\n")
s.send("PRIVMSG nickserv identify ac}pcut]eobosbec" + "\r\n")


def sendmsg(chan, msg):
    s.send("PRIVMSG "+ chan +" :"+ msg +"\n")

def ping():
    s.send("PONG :pingis\n")




while 1:
    feedback=feedback+s.recv(1024)
    print (feedback)
    if feedback.find("PING :") != -1:
        ping()
    if feedback.find("say hello Data") != -1:
        sendmsg("#zela", "Hello Data!")
    if feedback.find("tell us a joke Data") != -1:
        sendmsg("#zela", "but Captain, I don't know how.")
    if feedback.find("terminate Data") != -1:
        s.send("QUIT\r\n")

Now, everything works fine and Data responds to his commands correctly. He even quits when I tell him to. Unfortunately, once one of these commands is triggered, he will repeat himself every time I say something new, and then repeat himself forever until I turn him off.

<~Jordan> say hello Data
<Data> Hello Data!
<~Jordan> a
<Data> Hello Data!
<~Jordan> a
<~Jordan> a
<Data> Hello Data!
<Data> Hello Data!
<Data> Hello Data!
<Data> Hello Data!

I have tested to see if the server is resending messages to the bot, and it is not, so I figure it’s my fault and there is probably something very simple I am missing here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:41:41+00:00Added an answer on May 29, 2026 at 9:41 am

    You’re concatenating onto the end of feedback repeatedly, without clearing it:

    feedback=feedback+s.recv(1024)
    

    This will cause the if feedback.find("say hello Data") != -1: condition to always be true.

    You need to do something like feedback="" or remove the concatenation part of the above expression.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am learning Python slowly, and am trying to make a simple function
I have been slowly learning SQL the last few weeks. I've picked up all
I've been slowly working my way through the list of Project Euler problems, and
I have been slowly learning iPhone development and seem to keep hitting walls where
I've been learning Unity 3D, slowly. I'm trying to make a maze, and need
new guy here and I'm slowly getting the hang of python, but I have
I have been learning (slowly but surely) how to do deal with sqlite databases
We have a web e-learning type system, and for this project, I am supposed
I've just started learning Python and I'm slowly getting the hang of it, but
I'm slowly working through an Android learning book and was given the following code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.