This repository has been archived by the owner on Oct 21, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b3a5a2
commit cd28d60
Showing
3 changed files
with
112 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 | This is a team work of | ||
S. Sathianarayanan(sathia2704@gmail.com) & | S. Sathianarayanan(sathia2704@gmail.com) & | ||
S. Prasanna Venkadesh (prasmailme@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 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 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 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. | 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,67 +1,83 @@ | |||
|
|
||
begin | begin | ||
require 'rubygems' #Rubygems gem | require 'rubygems' #Rubygems gem | ||
require 'xmpp4r-simple' #Simple XML Protocol for Jabber API | require 'colorize' #gem used to set colors to text and backgrounds | ||
require "highline/import" #for password protection | require 'xmpp4r-simple' #Simple XML Protocol for Jabber API | ||
puts "Whiz Chat\nVersion - 1.0\t Developed by - S. Sathianarayanan(sathia2704@gmail.com)\nImproved by - S. Prasanna Venkadesh(prasmailme@gmail.com)\n" | require "highline/import" #for password protection | ||
print 'Enter the username :' | 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 | ||
username = gets.chomp #Get input from username for user-id | print 'Enter the username :' | ||
#gets password for mail account, ask from higline gem | username = gets.chomp #Get input from username for user-id | ||
password = ask("Enter the password :" ) { |p| p.echo = "*" } | #gets password for mail account, ask from higline gem | ||
print 'to address: ' | password = ask("Enter the password :" ) { |p| p.echo = "*" } | ||
@to_username = gets.chomp #prompt for userid to whom you want to chat with | print 'to address: ' | ||
puts "Connecting to jabber server.." | @to_username = gets.chomp #prompt for userid to whom you want to chat with | ||
@jabber = Jabber::Simple.new(username+'@gmail.com',password) #using jabber api to connect with gmail account. | puts "Connecting to jabber server.." | ||
system('clear') #to clear the console screen to keep the screen clean. | @jabber = Jabber::Simple.new(username+'@gmail.com',password) #using jabber api to connect with gmail account. | ||
puts "Connected.\nType bye to quit" #note you need to type 'bye' at terminal to quit the app. | system('clear') #to clear the console screen to keep the screen clean. | ||
@mess #a variable to get input message from you and also to quit from this chat. | 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 | #method to exit | ||
def quit | def quit | ||
#type 'bye' in terminal after logging in, you will be logged out. | #type 'bye' in terminal after logging in, you will be logged out. | ||
if(@mess=="bye") | system('clear') | ||
system('clear') | puts "Disconnected..." | ||
puts 'Disconnected...' | system('espeak "Bye Dude" >/dev/null 2>&1') | ||
exit() | exit() | ||
end | end | ||
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 | #for first time users who have not installed the required gems, this method will be run only once | ||
def receive | rescue LoadError | ||
#repeat until the user want to quit | print 'Dependencies was not installed. Do you want to install (y) or not (n)' | ||
while @mess!="bye" do | a = gets.chomp | ||
#method that reads the revceived message and puts in msg variable | if( a == 'y') | ||
@jabber.received_messages do |msg| | system('sudo gem install xmpp4r-simple') | ||
puts "==============================================" | system('sudo gem install highline') | ||
puts @to_username +": " + msg.body #display message in screen | system('sudo gem install colorize') | ||
puts Time.now #display the time of message received | end | ||
puts "**********************************************" | |||
sleep(2) #for multithreading | |||
end | |||
end | |||
end #end of receive method | |||
|
|
||
t1=Thread.new { send() } #instance for sending thread | rescue Jabber::ClientAuthenticationFailure | ||
t2=Thread.new { receive() } #instance for receiving thread | print "Invalid username / password\n".colorize(:red) + "Run again\n".colorize(:yellow) | ||
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 | #To handle interrupts | ||
print 'Dependencies was not installed. Do you want to install (y) or not (n)' | rescue Interrupt | ||
a = gets.chomp | puts "\nAborted By User..." | ||
if( a == 'y') |
|
||
system('sudo gem install xmpp4r-simple') | end | ||
system('sudo gem install highline') | |||
end | |||
end #end of method and program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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. | |||
|
|||
|