Jump to content

ChatLion


random667
 Share

Recommended Posts

This is my first full program made with autoit.

I even made a nice little lion icon for the compiled .exe

Triggers, responses and user name are now stored in an .ini so they can still be edited if the main script is compiled.

It will keep working even if chat program is minimized to tray.

i would like to set it up to have multiple responses per trigger (better yet, anyone want to help build a grammar engine to make this thing alot smarter?)

I dont really like the way the master commands are setup and would like to put them in a seperate .ini

I would like to find a way to keep the bot from stealing focus when it sends its responses.

Any improvement ideas are greatly appreciated.

ChatLion.au3

;===================================================================================================


=====
;=== ChatLion for Yahelite, By Random667
;===================================================================================================


=====
#include <GUIConstants.au3>

; Get users login name which is also the name of the chat application
$var = IniReadSection("user.ini", "name")
$loginname = $var[1][1]


; Check if login name saved
If $loginname = "" Then
    $bLoop = 1
    While $bLoop = 1
        
    ; If no login name saved open input box
        $loginname = InputBox("Login", "Please enter your login name and click OK")
        If @error = 1 Then
            Exit
        Else
            
        ; They clicked OK, but did they type?
            If $loginname = "" Then
                MsgBox(4096, "Error", "Try again!")
            Else
                
            ; if so save value to user.ini
                IniWrite("user.ini", "name", "user", $loginname)
                $bLoop = 0   ; Exit the loop - ExitLoop would have been an alternative too :)
            EndIf
        EndIf
    WEnd
EndIf

;set empty prevline var used later to check against new text
$prevline = ""


; Begin loop
$l = 0
Do
    
; Read from the chat window
    $totallines = ControlCommand($loginname, "", "RichEdit20A1", "GetLineCount", "")
    $currentline = ControlCommand($loginname, "", "RichEdit20A1", "GetLine", $totallines - 1)
    
; Check for new text
    If $prevline <> $currentline Then
        
    ; Store current text for check against new text
        $prevline = $currentline
        
    ; Get username from chat text
        $split = StringSplit($currentline, "*")
        $split2 = StringSplit($split[1], ":")
        $username = $split2[1]
        
    ;check if text is from other user
        $sameuser = StringInStr($username, $loginname)
        
    ; If comment is from other user
        If $sameuser = 0 Then
            
        ; Load trigger phrases and responses
            $tot = IniReadSection("triggers.ini", "totaltriggers")
            $totaltriggers = $tot[1][1]
            $trig = IniReadSection("triggers.ini", "triggers")
            $res = IniReadSection("triggers.ini", "response")
            For $i = 1 To $totaltriggers
                
            ; Replace variables from triggers.ini
                $trig2 = StringReplace($trig[$i][1], "*", "")
                $t = StringReplace($trig2, "@OWNER@", $loginname)
                $r = StringReplace($res[$i][1], "@USER@", $username)
                
            ; Remove username from chat text
                $currentlinecleaned = StringReplace($currentline, $username, "")
                
            ; Compare text to trigger phrases
                $found = StringInStr($currentlinecleaned, $t)
                
            ; If trigger phrase found send response to the input box
                If $found > 0 Then
                    
                ; get any text user may be typing into the inputbox
                    $input = ControlGetText($loginname, "", "Edit1")
                    
                ; Send response
                    ControlSetText($loginname, "", "Edit1", $r)
                    ControlClick($loginname, "", "Button1")
                    
                ; put any text user may be typing back into the inputbox
                    ControlSetText($loginname, "", "Edit1", $input)
                    ControlSend($loginname, "", "Edit1", "{END}")
                    
                EndIf
                
            ; Restart the For loop
            Next
        EndIf
        
    ; Check for master commands
        If $sameuser <> 0 Then
            
            
            
        ; Arrive in room
            $botoff = StringInStr($currentline, "arrives")
            If $botoff > 0 Then
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ; Send response
                ControlSetText($loginname, "", "Edit1", $loginname&" Has Entered The Room")
                ControlClick($loginname, "", "Button1")
                ControlSetText($loginname, "", "Edit1", "Bow Down Before The One You Serve, You're Going To Get What You Deserve!")
                ControlClick($loginname, "", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
            
            EndIf
            
            
            
        ; Turn off
            $botoff = StringInStr($currentline, "bot off")
            If $botoff > 0 Then
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ; Send response
                ControlSetText($loginname, "", "Edit1", "Shutdown complete.")
                ControlClick($loginname, "", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
                
                Exit
            EndIf
            
        ; Time
            $time = StringInStr($currentline, "bot time")
            If $time > 0 Then
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ; Send response
                ControlSetText($loginname, "", "Edit1", " It is now " & @HOUR & ":" & @MIN & ":" & @SEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR)
                ControlClick($loginname, "", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
                
            EndIf
            
        ; Sleep
            $sleep = StringInStr($currentline, "bot sleep")
            If $sleep > 0 Then
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ; Send response
                ControlSetText($loginname, "", "Edit1", "Taking a 5 minute nap now")
                ControlClick($loginname, "", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
                
                Sleep(50000)
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ; Snore
                ControlSetText($loginname, "", "Edit1", "ZZZzzz")
                ControlClick($loginname, "", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
                
                
                Sleep(50000)
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ; Snore
                ControlSetText($loginname, "", "Edit1", "ZZZZZzzzzz")
                ControlClick($loginname, "Edit1", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
                
                Sleep(50000)
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ; Snore
                ControlSetText($loginname, "", "Edit1", "ZZZZZZZZzzzzzz")
                ControlClick($loginname, "", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
                
                Sleep(50000)
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ; Snore
                ControlSetText($loginname, "", "Edit1", "ZZZZZZZZZZzzzzzzzzz")
                ControlClick($loginname, "", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
                
                Sleep(50000)
                
            ; get any text user may be typing into the inputbox
                $input = ControlGetText($loginname, "", "Edit1")
                
            ;wake up
                ControlSetText($loginname, "", "Edit1", "Yawn!, that was a good nap! Time to make the doughnuts!")
                ControlClick($loginname, "", "Button1")
                
            ; put any text user may be typing back into the inputbox
                ControlSetText($loginname, "", "Edit1", $input)
                ControlSend($loginname, "", "Edit1", "{END}")
                
            EndIf
        EndIf
        
    EndIf
; Restart the Do loop
Until $l = 1

Triggers.ini *most triggers removed due to vulgarity*

;===================================================================================================


=====
;=== ChatLion for Yahelite, By Random667
;===================================================================================================


=====
; Triggers and responses

[totaltriggers]
$Totaltriggers = 60

[triggers]

$T1 =  lol


$T2 = * rofl


$T3 =  what?


$T4 =  huh?


$T5 =  beer


$T6 =  vodka


[response]


$R1 = lol, Really Funny  @USER@ !


$R2 = rofl?, Get up  @USER@ , you idiot!


$R3 = huh?


$R4 = what?


$R5 = I want some beer  @USER@ !


$R6 = I want some vodka  @USER@ !

User.ini

[name]
user =

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Link to comment
Share on other sites

ok, i guess i should have given some instructions, my bad.

get yahelite(the best chat client),

get it setup and running,

start the bot script,

enter the same user name you logged into yahelite with when the bot asks.

in the triggers .ini the totaltriggers var will need to be changed to the actual amount of triggers you have setup.

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Link to comment
Share on other sites

  • 1 year later...

:whistle:

Kewlies !

Hope you do more

YahELite focused Scripts

You might even incorporate the YahELite Personality (.ypf) files, /MOTD , and /playfiles

:P

Edited by Gargy
01000001 01110101 01110100 01101111 01001001 01110100 00100000
An immortal object must be copied, so that we get a mortal copy of it, since we try not to destroy immortal objects.
Link to comment
Share on other sites

  • 2 months later...

Heya, random667

Duno if yer still around this forum dude, I came across this back in March but didn't have much time to sit down with it. Until now.

I had to edit your code a little, your headers had too long a line of " = " and it threw a spoke, so I managed to fix that :) no sweaties.

I noted it IS case sensitive on the login name input. You might want to mention that in the release notes. but certainly fixable by clearing off the wrong name case and restarting the app otherwise Chatlion will protest.

And I use Metapad to do my editing with, I set AutoIt as metapad's secondary viewer to run the app :) works great and lets me change / ad / edit emotes, macros, /playfiles, and so on wonderfully. And just a normal save for changes to take effect.

I don't even have to restart the app...unless I run into a bug.

BUG:

Which btw I did find.

I set up the triggers.ini to respond to anyone who's specific nastiness towards my screen name triggered YahELite's /ignore command which of course fires the ignore macro, heh. As a result I discovered that my silent iggy ctrl+dblclik username in roomlist was rendered nonfunctional. I'm going to try and see if maybe using <ignore!> macro instead will produce a better result. Will advise if that fixed the problem. I do suspect its the way YahElite is handling Chatlion's input.

Overall this little bot is userfriendly and works very well as a FAQ bot, One Liner tosser, room greeter...etc...all around fun while you're AFK. And its nice that it can deliver standard answers to standard questions that one gets tired of explaining lol

Maybe I'll add a trivia component to it later on :))

01000001 01110101 01110100 01101111 01001001 01110100 00100000
An immortal object must be copied, so that we get a mortal copy of it, since we try not to destroy immortal objects.
Link to comment
Share on other sites

  • 3 months later...

Heya, random667

Duno if yer still around this forum dude, I came across this back in March but didn't have much time to sit down with it. Until now.

I had to edit your code a little, your headers had too long a line of " = " and it threw a spoke, so I managed to fix that :) no sweaties.

I noted it IS case sensitive on the login name input. You might want to mention that in the release notes. but certainly fixable by clearing off the wrong name case and restarting the app otherwise Chatlion will protest.

And I use Metapad to do my editing with, I set AutoIt as metapad's secondary viewer to run the app :P works great and lets me change / ad / edit emotes, macros, /playfiles, and so on wonderfully. And just a normal save for changes to take effect.

I don't even have to restart the app...unless I run into a bug.

BUG:

Which btw I did find.

I set up the triggers.ini to respond to anyone who's specific nastiness towards my screen name triggered YahELite's /ignore command which of course fires the ignore macro, heh. As a result I discovered that my silent iggy ctrl+dblclik username in roomlist was rendered nonfunctional. I'm going to try and see if maybe using <ignore!> macro instead will produce a better result. Will advise if that fixed the problem. I do suspect its the way YahElite is handling Chatlion's input.

Overall this little bot is userfriendly and works very well as a FAQ bot, One Liner tosser, room greeter...etc...all around fun while you're AFK. And its nice that it can deliver standard answers to standard questions that one gets tired of explaining lol

Maybe I'll add a trivia component to it later on :))

how can this bot be able to KNOW how many line of text a users send into the room???? and read it

ive try this code into a chat room but ive only got the last line of text

if a user type

USER : line 1

line 2

line 3

i mean multi line before click the SEND button

the BOT only read the last LINE (LINE 3)

how can aproces can be made for GOT t the X number of line and why not in same time EXTRACT the users NICK

thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...