#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Beginner reply bot question


    Hello

    Im trying to make basic irc reply bot and i have question. My reply code looks like this at the moment:

    if data.find ( 'bot' ) != -1:
    irc.send ( 'PRIVMSG #channel :Yes i am bot\r\n' )

    Is it possible to make it not respond if letters "bot" are part of some word like robot or bottle.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    114
    Rep Power
    4
    Code:
    if "bot" in data.split():
        ... #do whatever
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    Perhaps something like this is what you need.
    Code:
    import re
    pattern = re.compile(r'\w')
    for match_object in pattern.finditer(data):
        if match_object.string == 'bot':
            print('Whoot!')
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo