Good To Know:


Oopsie!Either you knew everything or there was a problem in fetching my facts

Posted by : Unknown Sunday, 4 August 2013

facebook chat bot



Ever felt like " godd i wish some one could do the chatting behalf of me!" may the case be a boring person or even to use a fake account yes there is a way,and itz got a lot of potential you can use it for simple purposes like chatting or for more useful and complicated task automations.ok lets get started..


                                         for this we are going to use the WshShell object of windows script host.dont worry if you are not that familiar with it,just stay with me.

  • First copy the below code and pate it in your note pad.then click on save as and name it "bot.vbs" and don't forget to change the file type to "all files"
set kc = WScript.CreateObject("WScript.Shell")
WScript.Sleep 9000
kc.SendKeys "hello {:}{)} "
WScript.Sleep 2000
kc.SendKeys "{ENTER}"
WScript.Sleep 7000
kc.SendKeys "how are you?"
WScript.Sleep 2000
kc.SendKeys "{ENTER}"
WScript.Sleep 7000
         kc.SendKeys "i{'}m fine{,}thank you {:}D"
WScript.Sleep 2000
kc.SendKeys "{ENTER}"
WScript.Sleep 7000
kc.SendKeys "wassup?"
WScript.Sleep 2000
kc.SendKeys "{ENTER}"
WScript.Sleep 7000
kc.SendKeys "where do you live{?}"
WScript.Sleep 2000
kc.SendKeys "{ENTER}"
WScript.Sleep 7000
kc.SendKeys "oh{,}i{'}m from india"
WScript.Sleep 2000
kc.SendKeys "{ENTER}"
WScript.Sleep 7000
kc.SendKeys "ok{,}bye for now {:}D"
WScript.Sleep 2000
kc.SendKeys "{ENTER}"




  • I know its a little bit clumsy,but i'll explain it.ok now all you have to do is double click on the file,and then navigate to your browser and click on the chat box of the person with whom you want your bot to chat.
Explanation:


  • The above code is a bit lengthy,so let me take a small piece of code for the purpose of explanation,we'll get back to the original code later.

set kc = WScript.CreateObject("WScript.Shell")

WScript.Sleep 100

kc.Run "notepad.exe"

WScript.Sleep 100

kc.AppActivate "notepad"

WScript.Sleep 1000

kc.SendKeys "hello everyone {!} "


                                  ok,here it goes,
  • set kc = WScript.CreateObject("WScript.Shell")  - this line is used to create an object of "WScript shell" with a reference name "kc" you can use any name of your desire,but make sure you stick to the name through out the code.
  • WScript.Sleep 100    -  this is to give a delay off 100 milli seconds,or you can simply say execute the next line of code after 100 milli seconds.and the time shall always be given in terms of milli seconds.1second = 1000 milli seconds.so if you want to give a pause of 3 seconds you must write
                                          WScript.Sleep 3000    

  • kc.Run "notepad.exe" - this is to start a new notepad you can use this line to start any application
                               eg:   kc.Run "calc" - for calculator
                                      kc.Run "taskmgr" - for task manager
                                      kc.Run "cmd" - for command prompt
                                                                          here we started a notepad because,we want to test whether our script is working well or not
  • kc.AppActivate "notepad" - to make notepad the active window,its simply like clicking on the notepad for the editing cursor to appear
  • kc.SendKeys "hello everyone{!}" -  to send the keys "hello everyone!" it is like typing the string "hello everyone!" through your keyboard this is the main concept we use in our chat bot.and you must have noticed that the !  mark has been wrapped with two flower brackets or what ever you call them,it is because,special symbols(anything except a-z and 0-9 ) must be in those brackets.and here is a list of other keyboard keys you could use

               backspace              {BACKSPACE}
               enter                        {ENTER}
               escape                      {ESC}
               tab                            {TAB}

                                                  ok now lets just look into our previous code,does it make sense now?i suggest you guys to go through the code once again with the acquired knowledge and try to interpret it,or you can continue reading,

  • in the code we did not call up the node pad application,it is because we want the chat bot to enter text into the chat box of our Facebook friend,but not into note pad.
  • in the second line,we gave a delay of 9 seconds,it is because in the mean time you could open up your browser and click on the chat (the place where you enter the text).you can even increase the delay if you want,but make sure you you do it within the time
  • and after entering the text,we gave a delay of 2 seconds it is because,to make the other person feel like we are typing,you know Facebook shows that " xxxxxx is typing......." thing
  • and then after sending the text,we waited for 7 seconds,so that the other person can give a reply.
  • to stop it from executing,you have to close the wscript window opened
  • You can change the text to what ever you want but remember it is case sensitive and special characters must be enclosed in {},go play with it!
     

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Translate

Blogger Tips and Tricks

Popular Post

Random post

- Copyright © smartify me -

- Administered by Krishna Chaitanya -
Google+