Permalink
Browse files

Version 2.01

  • Loading branch information...
0 parents commit f2b53d2d187e84673fd83a850eeaba0279f0c4d6 Pras committed Sep 2, 2011
Showing with 167 additions and 0 deletions.
  1. +34 −0 README.txt
  2. +102 −0 chat.rb
  3. +31 −0 features.rdoc
@@ -0,0 +1,34 @@
+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 - 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 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 using 'sudo' command before it.
+
+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 your Google mail account user_id alone (Eg:prasmailme) and dont add (@gmail.com), it will be automatically appended.
+
+Step 8: Enter the password for your account.
+
+Step 9: In 'to address: ' type the recepient user_id like above in Step 6.
+
+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.
+
+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.
102 chat.rb
@@ -0,0 +1,102 @@
+=begin
+ Application Name: Whiz-Chat
+ Version: 2.01
+ License: GPL V2.0
+=end
+begin
+ 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
+
+ system('clear')
+ system('espeak "Welcome. Dude" >/dev/null 2>&1')
+ puts "Whiz Chat Version - 2.01\nDeveloped by- S. Sathianarayanan (sathia2704@gmail.com)\nImproved by- S. Prasanna Venkadesh (prasmailme@gmail.com)\nGithub Repository: https://github.com/PrasannaVenkadesh/Whiz-Chat\n".colorize( :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 username: '
+ @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.
+ system('espeak "Connected.." >/dev/null 2>&1')
+
+ puts " Do you want to set Status Message (y) or (n)"
+ @choic = gets.chomp
+ if(@choic == 'y')
+ puts 'Whats in your mind: '.colorize(:red)
+ temp = gets.chomp
+ @jabber.status(:chat,temp)
+ end
+
+ system('clear')
+ puts "You can now start chatting\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.
+ 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
+
+
+ #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 apt-get install rubygems1.8')
+ system('sudo gem install xmpp4r-simple')
+ system('sudo gem install highline')
+ system('sudo gem install colorize')
+ end
+
+ rescue Jabber::ClientAuthenticationFailure
+ print "Invalid username / password\n".colorize(:red) + "Run again\n".colorize(:yellow)
+
+
+ #To handle interrupts
+ rescue Interrupt
+ puts "\nAborted By User..."
+
+end
@@ -0,0 +1,31 @@
+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:
+ 1. Basic sending and receiving messages between users by gmail account.
+ 2. Color differentiation between sender and reciever chat.
+ 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.
+-------------------------------------------------------------------------------------------------------------------
+Features of Whiz-chat - 2.01 (Current):
+ 1. Basic sending and receiving messages between users by gmail account.
+ 2. Color differentiation between sender and reciever chat.
+ 3. Welcome message, Sound Alert on each received chat, Terminating alert.
+ ** 4. Setting the status message for your account.
+
+No Bugs were fixed since version 2.0
+-------------------------------------------------------------------------------------------------------------------
+
+

0 comments on commit f2b53d2

Please sign in to comment.