Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed /topic handler #194

Merged
merged 2 commits into from

2 participants

Spenser Jones David Petersen
Spenser Jones

Problem:
/topic This is a test # Would change the topic of channel "This"
to "is", and ignore the rest
/topic #Channel This is a test # Would change the topic of channel
"#Channel" to "This" and ignore the rest
Resolution:
If args[0] starts with # or &, a channel has been provided. Set the
channel's name to args.shift(), and the topic to args.join(' ')
If args[0] does not start with # or &, set the active channel's
topic to args.join(' ')

Spenser Jones SpenserJ Fixed /topic handler
Problem:
/topic This is a test # Would change the topic of channel "This"
    to "is", and ignore the rest
/topic #Channel This is a test # Would change the topic of channel
    "#Channel" to "This" and ignore the rest
Resolution:
If args[0] starts with # or &, a channel has been provided. Set the
    channel's name to args.shift(), and the topic to args.join(' ')
If args[0] does not start with # or &, set the active channel's
    topic to args.join(' ')
51eaec4
assets/js/client.js
@@ -425,11 +425,11 @@ $(function() {
});
irc.commands.add('topic', function(args){
- if (args[1]) {
- irc.socket.emit('topic', {name: args[0], topic: args[1]});
+ if (args[0].indexOf('#') == 0 || args[0].indexOf('&') == 0) {
David Petersen Owner

Just the same style comment: ===, and maybe a comment on what this comparison is doing then it looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
David Petersen thedjpetersen merged commit b6ce807 into from
David Petersen

Thanks!

Spenser Jones SpenserJ deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 24, 2012
  1. Spenser Jones

    Fixed /topic handler

    SpenserJ authored
    Problem:
    /topic This is a test # Would change the topic of channel "This"
        to "is", and ignore the rest
    /topic #Channel This is a test # Would change the topic of channel
        "#Channel" to "This" and ignore the rest
    Resolution:
    If args[0] starts with # or &, a channel has been provided. Set the
        channel's name to args.shift(), and the topic to args.join(' ')
    If args[0] does not start with # or &, set the active channel's
        topic to args.join(' ')
  2. Spenser Jones
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 assets/js/client.js
9 assets/js/client.js
View
@@ -425,11 +425,12 @@ $(function() {
});
irc.commands.add('topic', function(args){
- if (args[1]) {
- irc.socket.emit('topic', {name: args[0], topic: args[1]});
- } else {
+ // If args[0] starts with # or &, a topic name has been provided
+ if (args[0].indexOf('#') === 0 || args[0].indexOf('&') === 0) {
+ irc.socket.emit('topic', {name: args.shift(), topic: args.join(' ')});
+ } else { // Otherwise, assume we're changing the current channel's topic
irc.socket.emit('topic', {name: irc.chatWindows.getActive().get('name'),
- topic: args[0]});
+ topic: args.join(' ')});
}
});
Something went wrong with that request. Please try again.