リビジョン eb7a557c
みぞ @mizo0203 さんがほぼ7年前に追加
src/com/mizo0203/twitter/timeline/talker/TwitterTimelineTalker.java | ||
---|---|---|
1 | 1 |
package com.mizo0203.twitter.timeline.talker; |
2 | 2 |
|
3 | 3 |
import java.util.Locale; |
4 |
import java.util.regex.Matcher; |
|
5 |
import java.util.regex.Pattern; |
|
4 | 6 |
import twitter4j.StallWarning; |
5 | 7 |
import twitter4j.Status; |
6 | 8 |
import twitter4j.StatusDeletionNotice; |
... | ... | |
31 | 33 |
mTwitterStream.user(); |
32 | 34 |
} |
33 | 35 |
|
36 |
private static String getUserNameWithoutContext(String name) { |
|
37 |
Pattern p = Pattern.compile("([^@@]+).+"); |
|
38 |
Matcher m = p.matcher(name); |
|
39 |
return m.replaceFirst("$1"); |
|
40 |
} |
|
41 |
|
|
34 | 42 |
private class OnStatusEvent implements StatusListener { |
35 | 43 |
|
36 | 44 |
public void onStatus(final Status status) { |
... | ... | |
42 | 50 |
|
43 | 51 |
if (status.isRetweet()) { |
44 | 52 |
Status retweetedStatus = status.getRetweetedStatus(); |
45 |
buffer.append(status.getUser().getName() + "さんがリツイート。");
|
|
46 |
buffer.append(retweetedStatus.getUser().getName() + "さんから、");
|
|
53 |
buffer.append(getUserNameWithoutContext(status.getUser().getName()) + "さんがリツイート。");
|
|
54 |
buffer.append(getUserNameWithoutContext(retweetedStatus.getUser().getName()) + "さんから、");
|
|
47 | 55 |
buffer.append(retweetedStatus.getText()); |
48 | 56 |
} else { |
49 |
buffer.append(status.getUser().getName() + "さんから、");
|
|
57 |
buffer.append(getUserNameWithoutContext(status.getUser().getName()) + "さんから、");
|
|
50 | 58 |
buffer.append(status.getText()); |
51 | 59 |
} |
52 | 60 |
|
他の形式にエクスポート: Unified diff
Remove Context from User Name. fixes #239 @3h