Skip to content
This repository has been archived by the owner on Oct 21, 2019. It is now read-only.

Commit

Permalink
Version 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PrasannaVenkadesh committed Oct 25, 2011
1 parent 2a42229 commit c4d3656
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.txt
Expand Up @@ -4,7 +4,7 @@ This is a team work of
S. Sathianarayanan(http://sathia27.wordpress.com/) & S. Sathianarayanan(http://sathia27.wordpress.com/) &
S. Prasanna Venkadesh (http://prasopensource.wordpress.com/) S. Prasanna Venkadesh (http://prasopensource.wordpress.com/)


md5Checksum - fc3f95f8dbb6ec09b2ec13930d405505 chat.rb md5Checksum - bf7ed3306ab115750a94d9c541f8e16f chat.rb


Step 1: Download the file 'chat.rb' from the repository Step 1: Download the file 'chat.rb' from the repository


Expand Down
44 changes: 31 additions & 13 deletions chat.rb 100644 → 100755
@@ -1,7 +1,7 @@

#!/usr/bin/env ruby1.8
=begin =begin
Application Name: Whiz-Chat Application Name: Whiz-Chat
Version: 2.01 Version: 2.2
License: GPL V2.0 License: GPL V2.0
=end =end


Expand All @@ -10,22 +10,47 @@
require 'colorize' #gem used to set colors to text and backgrounds require 'colorize' #gem used to set colors to text and backgrounds
require 'xmpp4r-simple' #Simple XML Protocol for Jabber API require 'xmpp4r-simple' #Simple XML Protocol for Jabber API
require "highline/import" #for password protection require "highline/import" #for password protection
require 'gmail' #for gmail access


system('clear') system('clear')
system('espeak "Welcome. Dude" >/dev/null 2>&1') 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 puts "Whiz Chat Version - 2.2".colorize(:yellow)
puts "Developed 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 :' print 'Enter the username :'
username = gets.chomp #Get input from username for user-id username = gets.chomp #Get input from username for user-id
#gets password for mail account, ask from higline gem #gets password for mail account, ask from higline gem
password = ask("Enter the password :" ) { |p| p.echo = "*" } password = ask("Enter the password :" ) { |p| p.echo = "*" }

def quit
#type 'bye' in terminal after logging in, you will be logged out.
system('reset')
puts "You are now Disconnected"
system('espeak "Bye Dude" >/dev/null 2>&1')
exit()
end

begin
puts "Want to Chat or check Mail?\nc - chat\nm - mail\nq - quit"
@opt = gets.chomp
if(@opt == 'm')
Gmail.connect(username, password) do |gmail|
system('clear')
puts "You have "+ gmail.inbox.count(:unread).to_s + " unread mails"
end
end
if(@opt == 'q')
quit()
end
end while(@opt!='c')

print 'To username: ' print 'To username: '
@to_username = gets.chomp #prompt for userid to whom you want to chat with @to_username = gets.chomp #prompt for userid to whom you want to chat with
puts "Connecting to jabber server.." puts "Connecting to jabber server.."
@jabber = Jabber::Simple.new(username+'@gmail.com',password) #using jabber api to connect with gmail account. @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('clear') #to clear the console screen to keep the screen clean.
system('espeak "Connected.." >/dev/null 2>&1') system('espeak "Connected.." >/dev/null 2>&1')


puts " Do you want to set Status Message (y) or (n)" puts "Do you want to set Status Message (y) or (n)"
@choic = gets.chomp @choic = gets.chomp
if(@choic == 'y') if(@choic == 'y')
puts 'Whats in your mind: '.colorize(:red) puts 'Whats in your mind: '.colorize(:red)
Expand All @@ -37,15 +62,6 @@
puts "You can now start chatting\nType bye to quit" #note you need to type 'bye' at terminal to quit the app. 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. @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. #method to get input from you and to send to person you are in chat with.
def send def send
while @mess!="bye" do #repeat until the user want to quit while @mess!="bye" do #repeat until the user want to quit
Expand Down Expand Up @@ -96,6 +112,8 @@ def receive
rescue Jabber::ClientAuthenticationFailure rescue Jabber::ClientAuthenticationFailure
print "Invalid username / password\n".colorize(:red) + "Run again\n".colorize(:yellow) print "Invalid username / password\n".colorize(:red) + "Run again\n".colorize(:yellow)


rescue Net::IMAP::BadResponseError
print "Invalid username / password\n".colorize(:green) + "Run again\n".colorize(:yellow)


#To handle interrupts #To handle interrupts
rescue Interrupt rescue Interrupt
Expand Down

0 comments on commit c4d3656

Please sign in to comment.