Permalink
Browse files

Version 2.0

  • Loading branch information...
1 parent 9b3a5a2 commit cd28d606912fd77c4d73da172a9cd703fc40932a @PrasannaVenkadesh committed Aug 19, 2011
Showing with 112 additions and 70 deletions.
  1. +14 −10 README.txt
  2. +76 −60 chat.rb
  3. +22 −0 features.rdoc
View
@@ -1,30 +1,34 @@
-Whiz-Chat 1.0 is a ruby script through which terminal users can chat from terminal by using their Gmail account.
+Whiz-Chat is a ruby script for Linux through which terminal users can chat from terminal by using their Gmail account.
This is a team work of
S. Sathianarayanan(sathia2704@gmail.com) &
S. Prasanna Venkadesh (prasmailme@gmail.com)
-md5Checksum - 1ab9ca2dd12c1c4a21ea71ce3afe219d chat.rb
+md5Checksum - f6e1547a8dae8fdb644b2ed818e09c51 chat.rb
Step 1: Download the file 'chat.rb' from the repository
-Step 2: Make sure you have installed Ruby 1.8.x (Recommended) in your Linux box.
+Step 2: Make sure you have installed Ruby 1.8.x (Recommended) in your Linux box and have installed Rubygems1.8 (Recommended).
Step 3: Run the Ruby script like 'ruby chat.rb' from your terminal.
Step 4: Dependencies need to be satisfied for the first time, so type 'y' to satisfy dependencies from Internet.
-Step 5: Repeat step 3 again. If it again prompt for dependencies, do repeat step 3 as Super User.
+Step 5: Repeat step 3 again. If it again prompt for dependencies, do repeat step 3 as Super User using 'sudo' command before it.
-Step 6: Enter your Google mail account user_id alone (Eg:prasmailme) and dont add (@gmail.com), it will be automatically appended.
+Step 6: The above thing works only for Debian/Ubuntu users, and if you are an Redhat/Fedora based user please do install ruby1.8.x and Rubygems1.8 manually.
-Step 7: Enter the password for your account.
+Step 7: Enter your Google mail account user_id alone (Eg:prasmailme) and dont add (@gmail.com), it will be automatically appended.
-Step 8: In 'to address: ' type the recepient user_id like above in Step 6.
+Step 8: Enter the password for your account.
-Step 9: If everything went fine you have will be ready to send or receive messages, or else exceptions will be thrown for User_id / Password mismatch.
+Step 9: In 'to address: ' type the recepient user_id like above in Step 6.
-Step 10: Type 'bye' to quit from chat, the message bye will also be delivered for the receiver.
+Step 10: If everything went fine you have will be ready to send or receive messages, or else exceptions will be thrown for User_id / Password mismatch.
-We have a list of features to be implemented in next versions.
+Step 11: Type 'bye' to quit from chat, the message bye will also be delivered for the receiver.
+
+We have a list of features. Check features.rdoc file.
Please do help us by mailing the bugs you find.
+
+Note: We have used 'espeak' to make sound alerts and it comes as default in ubuntu 10.10 and 11.04, so if you are using some other distro or versions of linux see to that you have got that tool installed or install it manually.
View
136 chat.rb
@@ -1,67 +1,83 @@
begin
- require 'rubygems' #Rubygems gem
- require 'xmpp4r-simple' #Simple XML Protocol for Jabber API
- require "highline/import" #for password protection
- puts "Whiz Chat\nVersion - 1.0\t Developed by - S. Sathianarayanan(sathia2704@gmail.com)\nImproved by - S. Prasanna Venkadesh(prasmailme@gmail.com)\n"
- print 'Enter the username :'
- username = gets.chomp #Get input from username for user-id
- #gets password for mail account, ask from higline gem
- password = ask("Enter the password :" ) { |p| p.echo = "*" }
- print 'to address: '
- @to_username = gets.chomp #prompt for userid to whom you want to chat with
- puts "Connecting to jabber server.."
- @jabber = Jabber::Simple.new(username+'@gmail.com',password) #using jabber api to connect with gmail account.
- system('clear') #to clear the console screen to keep the screen clean.
- puts "Connected.\nType bye to quit" #note you need to type 'bye' at terminal to quit the app.
- @mess #a variable to get input message from you and also to quit from this chat.
+ require 'rubygems' #Rubygems gem
+ require 'colorize' #gem used to set colors to text and backgrounds
+ require 'xmpp4r-simple' #Simple XML Protocol for Jabber API
+ require "highline/import" #for password protection
+ puts "Whiz Chat\nVersion - 2.0\t Developed by - S. Sathianarayanan(sathia2704@gmail.com)\nImproved by - S. Prasanna Venkadesh(prasmailme@gmail.com)\n".colorize( :grey ).on_blue.underline
+ print 'Enter the username :'
+ username = gets.chomp #Get input from username for user-id
+ #gets password for mail account, ask from higline gem
+ password = ask("Enter the password :" ) { |p| p.echo = "*" }
+ print 'to address: '
+ @to_username = gets.chomp #prompt for userid to whom you want to chat with
+ puts "Connecting to jabber server.."
+ @jabber = Jabber::Simple.new(username+'@gmail.com',password) #using jabber api to connect with gmail account.
+ system('clear') #to clear the console screen to keep the screen clean.
+ puts "Connected.\nType bye to quit" #note you need to type 'bye' at terminal to quit the app.
+ @mess #a variable to get input message from you and also to quit from this chat.
-#method to exit
-def quit
- #type 'bye' in terminal after logging in, you will be logged out.
- if(@mess=="bye")
- system('clear')
- puts 'Disconnected...'
- exit()
- end
-end
+ #method to exit
+ def quit
+ #type 'bye' in terminal after logging in, you will be logged out.
+ system('clear')
+ puts "Disconnected..."
+ system('espeak "Bye Dude" >/dev/null 2>&1')
+ exit()
+ end
+
+ #method to get input from you and to send to person you are in chat with.
+ def send
+ while @mess!="bye" do #repeat until the user want to quit
+ @mess = gets.chomp #to get input message from user to chat
+ #method to send the message of user to recipeint.
+ @jabber.deliver(@to_username+"@gmail.com", @mess)
+ sleep(1) #for multithreading
+ end
+ quit()
+ end
+
+ #method to read and display the message from sender
+ def receive
+ #repeat until the user want to quit
+ while @mess!="bye" do
+ #method that reads the revceived message and puts in msg variable
+ @jabber.received_messages do |msg|
+ if msg.from.node == @to_username
+ puts "=============================================="
+ puts @to_username.colorize(:color => :black,:background => :yellow) +": " + msg.body.colorize(:green) #display message in screen
+ puts Time.now.to_s.colorize(:gray) #display the time of message received
+ system('espeak "Got message" > /dev/null 2>&1')
+ puts "**********************************************"
+ sleep(2) #for multithreading
+ end
+ end
+ end
+ quit()
+ end #end of receive method
+
+ t1=Thread.new { send() } #instance for sending thread
+ t2=Thread.new { receive() } #instance for receiving thread
+ t1.join #when encounters sleep, jumps to thread t2
+ t2.join #when encounters sleep, jumps to thread t1
-#method to get input from you and to send to person you are in chat with.
-def send
- while @mess!="bye" do #repeat until the user want to quit
- @mess = gets.chomp #to get input message from user to chat
- #method to send the message of user to recipeint.
- @jabber.deliver(@to_username+"@gmail.com", @mess)
- sleep(1) #for multithreading
- end
-end
-#method to read and display the message from sender
-def receive
- #repeat until the user want to quit
- while @mess!="bye" do
- #method that reads the revceived message and puts in msg variable
- @jabber.received_messages do |msg|
- puts "=============================================="
- puts @to_username +": " + msg.body #display message in screen
- puts Time.now #display the time of message received
- puts "**********************************************"
- sleep(2) #for multithreading
- end
- end
-end #end of receive method
+ #for first time users who have not installed the required gems, this method will be run only once
+ rescue LoadError
+ print 'Dependencies was not installed. Do you want to install (y) or not (n)'
+ a = gets.chomp
+ if( a == 'y')
+ system('sudo gem install xmpp4r-simple')
+ system('sudo gem install highline')
+ system('sudo gem install colorize')
+ end
-t1=Thread.new { send() } #instance for sending thread
-t2=Thread.new { receive() } #instance for receiving thread
-t1.join #when encounters sleep, jumps to thread t2
-t2.join #when encounters sleep, jumps to thread t1
+ rescue Jabber::ClientAuthenticationFailure
+ print "Invalid username / password\n".colorize(:red) + "Run again\n".colorize(:yellow)
-#for first time users who have not installed the required gems, this method will be run only once
-rescue LoadError
- print 'Dependencies was not installed. Do you want to install (y) or not (n)'
- a = gets.chomp
- if( a == 'y')
- system('sudo gem install xmpp4r-simple')
- system('sudo gem install highline')
- end
-end #end of method and program
+
+ #To handle interrupts
+ rescue Interrupt
+ puts "\nAborted By User..."
+
+end
View
@@ -0,0 +1,22 @@
+Features of Whiz-chat - 1.0:
+ 1. Basic sending and receiving messages between users by gmail account.
+
+Known Bugs:
+ 1. If more than one user chats, then all the chats will be displayed messing up (Debugged in version 2.0)
+ 2. Do not Works, if you are using proxy for your internet.
+ 3. Throws some Interrupt exceptions.
+
+Features of Whiz-chat - 2.0 (Current):
+ 1. Basic sending and receiving messages between users by gmail account.
+ 2. Added colors to display, differentiating messages between users.
+ 3. Sound Alert on each received chat.
+
+Bugs Fixed:
+ 1. User differentiation.
+ 2. No mixing of chats.
+ 3. Does not throw Interrupt exceptions.
+
+Known Bugs:
+ 1. Do not works, if you are using proxy for your internet.
+
+

0 comments on commit cd28d60

Please sign in to comment.