Closed rupansh closed 5 years ago
does the first example throw any error?
does the first example throw any error?
nope. But it doesn't change permissions
your first snippet works fine for me
your first snippet works fine for me
Weird. I shall try running it on my server
No luck. Here's are the procs which have the problem-
proc safeHandler*(b: TeleBot, c: Command) {.async.} =
let response = c.message
var failStr: string
if await isUserAdm(b, response.chat.id.int, response.fromUser.get.id):
if not (await canBotInfo(b, response)):
var msg = newMessage(response.chat.id, "I can't change chat permissions!")
msg.replyToMessageId = response.messageId
discard await b.send(msg)
return
var perm: ChatPermissions
var mode: string
if ' ' in response.text.get:
if response.text.get.split(" ").len > 1:
mode = response.text.get.split(" ")[^1]
if mode == "on":
perm = ChatPermissions(canSendMediaMessages: some(false))
elif mode == "off":
perm = ChatPermissions(canSendMediaMessages: some(true))
else:
var msg = newMessage(response.chat.id, "Invalid usage! please use on or off")
msg.replyToMessageId = response.messageId
discard await b.send(msg)
return
discard await setChatPermissions(b, $response.chat.id, perm)
var msg = newMessage(response.chat.id, "Safe mode " & mode)
msg.replyToMessageId = response.messageId
discard await b.send(msg)
/safemode on - Disables all permissions instead of just disabling media /safemode off - nothing happens, no error, i get safemode off message from bot as well
proc unmuteHandler*(b: TeleBot, c: Command) {.async.} =
let response = c.message
var unmuteId = 0
var failStr = "Reply to a user to unmute them!"
if not (await canBotRestrict(b, response)):
var msg = newMessage(response.chat.id, "I can't unmute users!")
msg.replyToMessageId = response.messageId
discard await b.send(msg)
return
if await isUserAdm(b, response.chat.id.int, response.fromUser.get.id):
if response.replyToMessage.isSome:
unmuteId = response.replyToMessage.get.fromUser.get.id
elif ' ' in response.text.get:
if response.text.get.split(" ").len > 1:
unmuteId = parseInt(response.text.get.split(" ")[^1])
if not (await isUserInChat(b, response.chat.id.int, unmuteId)):
unmuteId = 0
failStr = "Invalid user id"
if await isUserAdm(b, response.chat.id.int, unmuteId):
unmuteId = 0
failStr = "This guy can't be muted lol! so no need to unmute"
if unmuteId == 0:
var msg = newMessage(response.chat.id, failStr)
msg.replyToMessageId = response.messageId
discard await b.send(msg)
else:
let user = await getChatMember(b, $response.chat.id.int, unmuteId)
if not(user.canSendMessages.isNone or user.canSendMessages.get):
let perms = ChatPermissions(canSendMessages: some(true),
canSendMediaMessages: some(true),
canSendOtherMessages: some(true),
canAddWebPagePreviews: some(true))
discard await restrictChatMember(b, $response.chat.id, unmuteId, perms)
var msg = newMessage(response.chat.id, "User Un-Muted!")
msg.replyToMessageId = response.messageId
discard await b.send(msg)
else:
var msg = newMessage(response.chat.id, "User was never muted")
msg.replyToMessageId = response.messageId
discard await b.send(msg)
else:
var msg = newMessage(response.chat.id, "You aren't Adm :^(")
msg.replyToMessageId = response.messageId
discard await b.send(msg)
/unmute - does nothing, no error, I get positive response message though
maybe a bug on server side, I will check it again tonight
there was a typo fix after 0.6.7 but I forgot to make a new release, can you try again w/ new version 0.6.8?
there was a typo fix after 0.6.7 but I forgot to make a new release, can you try again w/ new version 0.6.8?
fixed!
Ex-
Doesn't work Expected behaviour: Should unrestrict the group
While
works fine