@@ -1116,9 +1116,22 @@ class VimChatScope:
1116
1116
def openGroupChat (self ):
1117
1117
accounts = self .showAccountList ()
1118
1118
1119
- account = accounts[int (vim .eval (
1120
- ' input("Account (enter the number from the above list): ")' ))]
1119
+ input = vim .eval (
1120
+ ' input("Account (enter the number from the above list): ")' )
1121
+ if not re .match (r ' \d+$' , input ):
1122
+ vim .command (' echohl ErrorMsg' )
1123
+ vim .command (' echo "\\nYou must enter an integer corresponding'
1124
+ + ' to an account."' )
1125
+ vim .command (' echohl None' )
1126
+ return
1127
+ index = int (input )
1128
+ if index < 0 or index >= len (accounts):
1129
+ vim .command (' echohl ErrorMsg' )
1130
+ vim .command (r ' echo "\nInvalid account number. Try again."' )
1131
+ vim .command (' echohl None' )
1132
+ return
1121
1133
1134
+ account = accounts[index ]
1122
1135
chatroom = vim .eval (' input("Chat Room to join: ")' )
1123
1136
name = vim .eval (' input("Name to Use: ")' )
1124
1137
self .groupChatNames.append (name)
@@ -1141,42 +1154,6 @@ class VimChatScope:
1141
1154
return accounts
1142
1155
#}}}
1143
1156
1144
- #NOTIFY
1145
- #{{{ notify
1146
- def notify (self , jid, msg, groupChat):
1147
- # Important to keep this print statement . As a side effect, it
1148
- # refreshes the buffer so the new message shows up .
1149
- print " Message Received from: " + jid
1150
-
1151
- if groupChat:
1152
- myNames = map (lambda x : x .split (' @' )[0 ], self .accounts.keys ())
1153
- myNames.extend (self .groupChatNames)
1154
- foundMyName = False
1155
- for name in myNames:
1156
- if name in msg:
1157
- foundMyName = True
1158
- break
1159
- if not foundMyName:
1160
- return
1161
-
1162
- vim .command (" set tabline=%#Error#New-message-from-" + jid);
1163
-
1164
- if pynotify_enabled and ' DBUS_SESSION_BUS_ADDRESS' in os.environ :
1165
- pynotify.init (' vimchat' )
1166
- n = pynotify.Notification (jid + ' says: ' , msg, ' dialog-warning' )
1167
- n .set_timeout (10000 )
1168
- n .show ()
1169
-
1170
- if gtk_enabled:
1171
- self .statusIcon.blink (True)
1172
- #}}}
1173
- #{{{ clearNotify
1174
- def clearNotify (self ):
1175
- vim .command (' set tabline&' )
1176
- if gtk_enabled:
1177
- self .statusIcon.blink (False)
1178
- #}}}
1179
-
1180
1157
#LOGGING
1181
1158
#{{{ log
1182
1159
def log (self , account, user , msg):
@@ -1348,6 +1325,40 @@ class VimChatScope:
1348
1325
# Notify
1349
1326
self .notify (jid, message, groupChat)
1350
1327
#}}}
1328
+ #{{{ notify
1329
+ def notify (self , jid, msg, groupChat):
1330
+ # Important to keep this print statement . As a side effect, it
1331
+ # refreshes the buffer so the new message shows up .
1332
+ print " Message Received from: " + jid
1333
+
1334
+ if groupChat:
1335
+ myNames = map (lambda x : x .split (' @' )[0 ], self .accounts.keys ())
1336
+ myNames.extend (self .groupChatNames)
1337
+ foundMyName = False
1338
+ for name in myNames:
1339
+ if name in msg:
1340
+ foundMyName = True
1341
+ break
1342
+ if not foundMyName:
1343
+ return
1344
+
1345
+ vim .command (" set tabline=%#Error#New-message-from-" + jid);
1346
+
1347
+ if pynotify_enabled and ' DBUS_SESSION_BUS_ADDRESS' in os.environ :
1348
+ pynotify.init (' vimchat' )
1349
+ n = pynotify.Notification (jid + ' says: ' , msg, ' dialog-warning' )
1350
+ n .set_timeout (10000 )
1351
+ n .show ()
1352
+
1353
+ if gtk_enabled:
1354
+ self .statusIcon.blink (True)
1355
+ #}}}
1356
+ #{{{ clearNotify
1357
+ def clearNotify (self ):
1358
+ vim .command (' set tabline&' )
1359
+ if gtk_enabled:
1360
+ self .statusIcon.blink (False)
1361
+ #}}}
1351
1362
1352
1363
#OTR
1353
1364
#{{{ otrVerifyBuddy
0 commit comments