-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch_purple.sh
66 lines (50 loc) · 1.73 KB
/
search_purple.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# modify the next four lines for your system
EMAIL="[email protected]"
PIDGIN_HOME="/home/user/.purple/logs/irc/[email protected]/\#osm-bot.chat"
AREA="Washington, United State"
SCRIPT_HOME="/home/user/bin"
cd $PIDGIN_HOME
CURRENT=`(ls -t | head -1)`
grep $AREA $CURRENT|grep "just started editing" >> /tmp/found.txt
while read line
do
USR=`echo $line |sed -e '/.*osmbot.test. /s///' -e '/ just started.*/s///' -e 's/[\/&]/\\&/g'`
USER=`echo "$USR" | sed -e 's/[\$\^\&]/\\\&/g'`
if ! grep -q "$USER" $SCRIPT_HOME/newuser/newuser.txt
then
CHANGESET=`echo $line | sed -e '/.*changeset /s///'`
echo "$USR" >> $SCRIPT_HOME/newuser/newuser.txt
MUSR=`echo "$USER" | sed -e 's/ /%20/g' -e 's;^;http://openstreetmap.org/message/new/;'`
echo -e "$MUSR" '\t' $CHANGESET >> /tmp/both.txt
fi
done </tmp/found.txt
if test -e /tmp/both.txt; then
mailx -s "New User" $EMAIL </tmp/both.txt
rm /tmp/both.txt
fi
if test -e /tmp/found.txt; then
rm /tmp/found.txt
fi
# NOTES Section
grep $AREA $CURRENT|grep "posted a new note near" >> /tmp/found2.txt
while read line
do
USR=`echo $line |sed -e '/.*osmbot.test: /s///' -e '/ posted a new note.*/s///' -e 's/[\/&]/\\&/g'`
NOTEID=`echo $line|sed -e '/.*new note near .*http/s//https/' -e '/ \(.*\)/s///'`
NOTE=`echo $line|sed -r 's;^.*(https://osm.org/note/[0-9]+) .\"(.*)\".*;\2;'`
if ! grep -q "$CHANGESET" $SCRIPT_HOME/purple/changeset.txt
then
echo "$NOTEID" >> $SCRIPT_HOME/purple/changeset.txt
echo -e "$USR" '\t' $CHANGESET '\t' $NOTE >> /tmp/notes.txt
fi
done </tmp/found2.txt
if test -e /tmp/notes.txt; then
mailx -s "New Note" $SCRIPT_HOME </tmp/notes.txt
rm /tmp/notes.txt
# cat /tmp/notes.txt
fi
if test -e /tmp/found2.txt; then
rm /tmp/found2.txt
# cat /tmp/found2.txt
fi